]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix leak on OOM in qemuBuildCommandLine dealing with sound card
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Sep 2013 15:26:18 +0000 (16:26 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 14:49:27 +0000 (15:49 +0100)
The qemuBuildCommandLine code for parsing sound cards will leak
an intermediate variable if an OOM occurs. Move the free'ing of
the variable earlier to avoid the leak.

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

index 50b4d70aa83136fbb9b7e738898e6c9673075307..caabf81d6e0ff577535820a97a2bfcefbce8bc37 100644 (file)
@@ -9102,7 +9102,7 @@ qemuBuildCommandLine(virConnectPtr conn,
                         goto error;
 
                     virCommandAddArg(cmd, str);
-
+                    VIR_FREE(str);
                     if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
                         sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
                         char *codecstr = NULL;
@@ -9130,8 +9130,6 @@ qemuBuildCommandLine(virConnectPtr conn,
                             VIR_FREE(codecstr);
                         }
                     }
-
-                    VIR_FREE(str);
                 }
             }
         } else {