* lib/hash.c (hash_initialize): Detect calloc failure.
authorJim Meyering <jim@meyering.net>
Sun, 9 Sep 2007 14:48:10 +0000 (14:48 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 9 Sep 2007 14:48:10 +0000 (14:48 +0000)
Reported by Bruno Haible.

ChangeLog
lib/hash.c

index e68568eaf6faf94c336b15ac783c5553062316db..3338c6fe738a820000435af8b938626bf855bb89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-09  Jim Meyering  <jim@meyering.net>
+
+       * lib/hash.c (hash_initialize): Detect calloc failure.
+       Reported by Bruno Haible.
+
 2007-09-09  Bruno Haible  <bruno@clisp.org>
 
        * lib/canonicalize-lgpl.c (__realpath): Set errno to ENOMEM when
index f4ab12f487de70ed85be317277df43d16176ce67..f0f481b32817706ec4fd403e66a43831b161b2b7 100644 (file)
@@ -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 Hash_tuning *tuning,
     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;