]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix memory leak on OOM in virSecuritySELinuxMCSFind
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 13 Mar 2013 17:39:52 +0000 (17:39 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 14 Mar 2013 12:42:21 +0000 (12:42 +0000)
The body of the loop in virSecuritySELinuxMCSFind would
directly 'return NULL' on OOM, instead of jumping to the
cleanup label. This caused a leak of several local vars.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/security/security_selinux.c

index a042b26845faa2ffc6d600079e1dddff04678108..f1399af5ae1dfc57c4f5af3f344bb9a6ccd52297 100644 (file)
@@ -214,7 +214,7 @@ virSecuritySELinuxMCSFind(virSecurityManagerPtr mgr)
         if (c1 == c2) {
             if (virAsprintf(&mcs, "%s:c%d", sens, catMin + c1) < 0) {
                 virReportOOMError();
-                return NULL;
+                goto cleanup;
             }
         } else {
             if (c1 > c2) {
@@ -224,7 +224,7 @@ virSecuritySELinuxMCSFind(virSecurityManagerPtr mgr)
             }
             if (virAsprintf(&mcs, "%s:c%d,c%d", sens, catMin + c1, catMin + c2) < 0) {
                 virReportOOMError();
-                return NULL;
+                goto cleanup;
             }
         }