Module Name: src
Committed By: wiz
Date: Tue Jan 4 09:58:03 UTC 2011
Modified Files:
src/usr.sbin/pstat: pstat.c
Log Message:
Fix memory leak in error case. Found by cppcheck.
To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/usr.sbin/pstat/pstat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/pstat/pstat.c
diff -u src/usr.sbin/pstat/pstat.c:1.116 src/usr.sbin/pstat/pstat.c:1.117
--- src/usr.sbin/pstat/pstat.c:1.116 Thu Nov 19 02:52:54 2009
+++ src/usr.sbin/pstat/pstat.c Tue Jan 4 09:58:03 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pstat.c,v 1.116 2009/11/19 02:52:54 enami Exp $ */
+/* $NetBSD: pstat.c,v 1.117 2011/01/04 09:58:03 wiz Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95";
#else
-__RCSID("$NetBSD: pstat.c,v 1.116 2009/11/19 02:52:54 enami Exp $");
+__RCSID("$NetBSD: pstat.c,v 1.117 2011/01/04 09:58:03 wiz Exp $");
#endif
#endif /* not lint */
@@ -926,6 +926,7 @@
err(1, "malloc");
if (sysctl(mib, 6, buf + offset, &len, NULL, 0) == -1) {
warn("sysctl: 2nd KERN_FILE2");
+ free(buf);
return (-1);
}
*abuf = buf;