xentop: fix potential memory leak
authorCharles Arnold <carnold@suse.com>
Thu, 2 Apr 2015 15:42:02 +0000 (09:42 -0600)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 2 Apr 2015 15:51:00 +0000 (16:51 +0100)
On a read failure the qstats buffer is not freed.

Signed-off-by: Charles Arnold <carnold@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/xenstat/libxenstat/src/xenstat_qmp.c

index c217b8e78b965de973f5185f715cef76dbdf6954..2cb99e9a607fbad00d20e10cadb1a6b77e0db783 100644 (file)
@@ -298,6 +298,7 @@ static int qmp_read(int qfd, unsigned char **qstats)
        while ((n = poll(pfd, POLLIN, 10)) > 0) {
                if (pfd[0].revents & POLLIN) {
                        if ((n = read(qfd, buf, sizeof(buf))) < 0) {
+                               free(*qstats);
                                return 0;
                        }
                        ptr = realloc(*qstats, qsize+n+1);