Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/locale Close file handles in error cases. Found by ...



details:   https://anonhg.NetBSD.org/src/rev/1180cc0e5449
branches:  trunk
changeset: 750883:1180cc0e5449
user:      wiz <wiz%NetBSD.org@localhost>
date:      Sun Jan 17 23:12:30 2010 +0000

description:
Close file handles in error cases. Found by cppcheck.

diffstat:

 lib/libc/locale/ctypeio.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 9a1a37b1068f -r 1180cc0e5449 lib/libc/locale/ctypeio.c
--- a/lib/libc/locale/ctypeio.c Sun Jan 17 23:10:20 2010 +0000
+++ b/lib/libc/locale/ctypeio.c Sun Jan 17 23:12:30 2010 +0000
@@ -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;
 }



Home | Main Index | Thread Index | Old Index