[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: missing check for malloc NULL result
From: |
Jim Meyering |
Subject: |
Re: missing check for malloc NULL result |
Date: |
Sun, 09 Sep 2007 16:57:53 +0200 |
> At these places malloc/realloc/calloc NULL results are not well handled, IIUC.
I fixed the hash.c one:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=summary
* lib/hash.c (hash_initialize): Detect calloc failure.
Reported by Bruno Haible.
=============================================================================
Index: lib/hash.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/hash.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -p -u -r1.40 -r1.41
--- lib/hash.c 13 Sep 2006 22:38:14 -0000 1.40
+++ lib/hash.c 9 Sep 2007 14:48:10 -0000 1.41
@@ -1,6 +1,6 @@
/* hash - hashing table processing.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007 Free
Software Foundation, Inc.
Written by Jim Meyering, 1992.
@@ -576,6 +576,8 @@ hash_initialize (size_t candidate, const
goto fail;
table->bucket = calloc (table->n_buckets, sizeof *table->bucket);
+ if (table->bucket == NULL)
+ goto fail;
table->bucket_limit = table->bucket + table->n_buckets;
table->n_buckets_used = 0;
table->n_entries = 0;