[libvirt] [PATCH] qemu: Fix a memory leak in qemudExtractTTYPath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index daa6f94..8817565 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;                                                \
+            }                                                             \
         }                                                                 \
     }
 
-- 
1.6.0.4

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]