Skip to contentSkip to conversation

xentop: fix potential memory leak

PATCH In review Charles Arnold 2 participants 2 messages Apr 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xentop: fix potential memory leak

On a read failure the qstats buffer is not freed.

tools/xenstat/libxenstat/src/xenstat_qmp.c +1 -0
index c217b8e..2cb99e9 100644
@@ -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);