]> xenbits.xensource.com Git - qemu-xen-4.6-testing.git/commitdiff
qemu-char: fix memory leak in qemu_char_open_pty()
authorKaifeng Zhu <kaifeng.zhu@citrix.com>
Fri, 7 Mar 2014 15:27:36 +0000 (15:27 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Oct 2015 15:52:06 +0000 (16:52 +0100)
The momery pointed by s and chr could be leaked if openpty return a value
less then 0.

Signed-off-by: Kaifeng Zhu <kaifeng.zhu@citrix.com>
Coverity-IDs: 1055926 1055927
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
qemu-char.c

index 324ed16ec73b5f19b300a7a43ba95526a2d48406..f62a6afb71b636ec0c7bfea4664c6ac42bbf4968 100644 (file)
@@ -932,6 +932,8 @@ static CharDriverState *qemu_chr_open_pty(void)
     s = qemu_mallocz(sizeof(PtyCharDriver));
 
     if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
+        qemu_free(s);
+        qemu_free(chr);
         return NULL;
     }