X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgl_anyhash_list2.h;fp=lib%2Fgl_anyhash_list2.h;h=db764bc5112995f4fa3f123164df778d2576eeea;hb=766d4f1de6c26bb084382524eaed00b45ab3112c;hp=03640f4cbc8ee07acd26e070563f969ecb101e4e;hpb=8fe59d16da6be1fbd1a3a9e507d620bd381b00da;p=gnulib.git diff --git a/lib/gl_anyhash_list2.h b/lib/gl_anyhash_list2.h index 03640f4cb..db764bc51 100644 --- a/lib/gl_anyhash_list2.h +++ b/lib/gl_anyhash_list2.h @@ -1,5 +1,5 @@ /* Sequential list data type implemented by a hash table with another list. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -99,9 +99,16 @@ hash_resize (gl_list_t list, size_t estimate) { gl_hash_entry_t *old_table = list->table; /* Allocate the new table. */ - gl_hash_entry_t *new_table = XCALLOC (new_size, gl_hash_entry_t); + gl_hash_entry_t *new_table; size_t i; + if (size_overflow_p (xtimes (new_size, sizeof (gl_hash_entry_t)))) + goto fail; + new_table = + (gl_hash_entry_t *) calloc (new_size, sizeof (gl_hash_entry_t)); + if (new_table == NULL) + goto fail; + /* Iterate through the entries of the old table. */ for (i = list->table_size; i > 0; ) { @@ -123,4 +130,9 @@ hash_resize (gl_list_t list, size_t estimate) list->table_size = new_size; free (old_table); } + return; + + fail: + /* Just continue without resizing the table. */ + return; }