]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Fix a memory leak in qemudExtractTTYPath
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 9 Jan 2010 20:19:08 +0000 (21:19 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Mon, 11 Jan 2010 22:58:56 +0000 (23:58 +0100)
qemudWaitForMonitor calls qemudReadLogOutput with qemudFindCharDevicePTYs
as callback. qemudFindCharDevicePTYs calls qemudExtractTTYPath to assign
a string to chr->data.file.path. Afterwards qemudWaitForMonitor may call
qemudFindCharDevicePTYsMonitor that overwrites chr->data.file.path without
freeing the old value. This results in leaking the memory allocated by
qemudExtractTTYPath.

Report an OOM error if the strdup in qemudFindCharDevicePTYsMonitor fails.

src/qemu/qemu_driver.c

index daa6f947f622b187c011ee7da6f86d3a2e5a27bb..881756568885085997a031ec85ab2520955bd5f0 100644 (file)
@@ -1433,7 +1433,13 @@ qemudFindCharDevicePTYsMonitor(virConnectPtr conn,
                 return -1;                                                \
             }                                                             \
                                                                           \
+            VIR_FREE(chr->data.file.path);                                \
             chr->data.file.path = strdup(path);                           \
+                                                                          \
+            if (chr->data.file.path == NULL) {                            \
+                virReportOOMError(conn);                                  \
+                return -1;                                                \
+            }                                                             \
         }                                                                 \
     }