From: Matthias Bolte Date: Sat, 9 Jan 2010 20:19:08 +0000 (+0100) Subject: qemu: Fix a memory leak in qemudExtractTTYPath X-Git-Tag: v0.7.6~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f01ee2acc84100a92288c2bb253c9bd48403949e;p=thirdparty%2Flibvirt.git qemu: Fix a memory leak in qemudExtractTTYPath 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. --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index daa6f947f6..8817565688 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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; \ + } \ } \ }