From 914e713d0787d4db80e29b1aa0a26e0fd5c929fa Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 11 Jun 2009 14:42:12 +0200 Subject: [PATCH] hash: check insertion for memory exhaustion. * src/muscle-tab.c (muscle_insert, muscle_grow) * src/state.c (state_hash_insert): Check the return value of hash_insert. --- ChangeLog | 7 +++++++ src/muscle_tab.c | 6 ++++-- src/state.c | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96cbb7de..6b155a4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-06-11 Akim Demaille + + hash: check insertion for memory exhaustion. + * src/muscle-tab.c (muscle_insert, muscle_grow) + * src/state.c (state_hash_insert): Check the return value of + hash_insert. + 2009-06-10 Akim Demaille gnulib: update. diff --git a/src/muscle_tab.c b/src/muscle_tab.c index 43415716..0137700f 100644 --- a/src/muscle_tab.c +++ b/src/muscle_tab.c @@ -121,7 +121,8 @@ muscle_insert (char const *key, char const *value) /* First insertion in the hash. */ entry = xmalloc (sizeof *entry); entry->key = key; - hash_insert (muscle_table, entry); + if (!hash_insert (muscle_table, entry)) + xalloc_die (); } else free (entry->storage); @@ -150,7 +151,8 @@ muscle_grow (const char *key, const char *val, const char *separator) /* First insertion in the hash. */ entry = xmalloc (sizeof *entry); entry->key = key; - hash_insert (muscle_table, entry); + if (!hash_insert (muscle_table, entry)) + xalloc_die (); entry->value = entry->storage = xstrdup (val); } else diff --git a/src/state.c b/src/state.c index d3460c15..40139868 100644 --- a/src/state.c +++ b/src/state.c @@ -352,7 +352,8 @@ state_hash_free (void) void state_hash_insert (state *s) { - hash_insert (state_table, s); + if (!hash_insert (state_table, s)) + xalloc_die (); } -- 2.45.2