Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/ssp Free malloc()ed buffer in error case. Found by ...
details: https://anonhg.NetBSD.org/src/rev/637537d72344
branches: trunk
changeset: 750884:637537d72344
user: wiz <wiz%NetBSD.org@localhost>
date: Sun Jan 17 23:13:32 2010 +0000
description:
Free malloc()ed buffer in error case. Found by cppcheck.
diffstat:
lib/libc/ssp/gets_chk.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (30 lines):
diff -r 1180cc0e5449 -r 637537d72344 lib/libc/ssp/gets_chk.c
--- a/lib/libc/ssp/gets_chk.c Sun Jan 17 23:12:30 2010 +0000
+++ b/lib/libc/ssp/gets_chk.c Sun Jan 17 23:13:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gets_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $ */
+/* $NetBSD: gets_chk.c,v 1.6 2010/01/17 23:13:32 wiz Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: gets_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: gets_chk.c,v 1.6 2010/01/17 23:13:32 wiz Exp $");
/*LINTLIBRARY*/
@@ -54,8 +54,10 @@
if ((abuf = malloc(slen + 1)) == NULL)
return gets(buf);
- if (fgets(abuf, (int)(slen + 1), stdin) == NULL)
+ if (fgets(abuf, (int)(slen + 1), stdin) == NULL) {
+ free(abuf);
return NULL;
+ }
len = strlen(abuf);
if (len > 0 && abuf[len - 1] == '\n')
Home |
Main Index |
Thread Index |
Old Index