Module Name:    src
Committed By:   wiz
Date:           Sun Jan 17 23:12:30 UTC 2010

Modified Files:
        src/lib/libc/locale: ctypeio.c

Log Message:
Close file handles in error cases. Found by cppcheck.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/ctypeio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/locale/ctypeio.c
diff -u src/lib/libc/locale/ctypeio.c:1.10 src/lib/libc/locale/ctypeio.c:1.11
--- src/lib/libc/locale/ctypeio.c:1.10	Wed Oct 21 01:07:45 2009
+++ src/lib/libc/locale/ctypeio.c	Sun Jan 17 23:12:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: ctypeio.c,v 1.10 2009/10/21 01:07:45 snj Exp $ */
+/* $NetBSD: ctypeio.c,v 1.11 2010/01/17 23:12:30 wiz Exp $ */
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -26,7 +26,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ctypeio.c,v 1.10 2009/10/21 01:07:45 snj Exp $");
+__RCSID("$NetBSD: ctypeio.c,v 1.11 2010/01/17 23:12:30 wiz Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -74,8 +74,10 @@
 
 	ptr = malloc(sizeof(*data) + ((sizeof(uint8_t) +
 	    sizeof(int16_t) + sizeof(int16_t)) * (len + 1)));
-	if (ptr == NULL)
+	if (ptr == NULL) {
+		fclose(fp);
 		return ENOMEM;
+	}
 
 	data = (_BSDCTypeLocale *)(void *)ptr;
 	ptr += sizeof(*data);
@@ -117,5 +119,6 @@
 bad1:
 	free(data);
 bad0:
+	fclose(fp);
 	return EFTYPE;
 }

Reply via email to