From 267dda075bc8d85ea70c222ad5ae1df13f896fa8 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Thu, 23 Jun 2011 15:24:52 +0200 Subject: [PATCH] Coverity: RESOURCE_LEAK src/hash.c:783: var_assign: Assigning: "new_table" = storage returned from "hash_initialize(candidate, table->tuning, table->hasher, table->comparator, table->data_freer)". src/hash.c:816: leaked_storage: Variable "new_table" going out of scope leaks the storage it points to. src/html.c:428: var_assign: Assigning: "table" = storage returned from "hash_initialize(0U, NULL, code_hash, code_compare, NULL)". src/html.c:436: leaked_storage: Variable "table" going out of scope leaks the storage it points to. src/html.c:609: var_assign: Assigning: "table" = storage returned from "hash_initialize(0U, NULL, string_hash, string_compare, NULL)". src/html.c:617: leaked_storage: Variable "table" going out of scope leaks the storage it points to. src/request.c:758: var_assign: Assigning: "new" = storage returned from "recode_malloc(outer, 16UL)". src/request.c:768: leaked_storage: Variable "new" going out of scope leaks the storage it points to. --- src/hash.c | 5 ++++- src/html.c | 10 ++++++++-- src/request.c | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/hash.c b/src/hash.c index d8ba8d5..8f9e1e3 100644 --- a/src/hash.c +++ b/src/hash.c @@ -860,7 +860,10 @@ hash_rehash (Hash_table *table, size_t candidate) struct hash_entry *new_entry = allocate_entry (new_table); if (new_entry == NULL) - return false; + { + hash_free (new_table); + return false; + } new_entry->data = data; new_entry->next = new_bucket->next; diff --git a/src/html.c b/src/html.c index 2f4a340..05e1fd5 100644 --- a/src/html.c +++ b/src/html.c @@ -435,7 +435,10 @@ init_ucs2_html (RECODE_STEP step, if (cursor->flags & mask && (!request->diacritics_only || cursor->code > 128)) if (!hash_insert (table, cursor)) - return false; + { + hash_free (table); + return false; + } step->step_type = RECODE_UCS2_TO_STRING; step->step_table = table; @@ -616,7 +619,10 @@ init_html_ucs2 (RECODE_STEP step, if (cursor->flags & mask && (!request->diacritics_only || cursor->code > 128)) if (!hash_insert (table, cursor)) - return false; + { + hash_free (table); + return false; + } step->step_type = RECODE_STRING_TO_UCS2; step->step_table = table; diff --git a/src/request.c b/src/request.c index 9964425..d1bbaaf 100644 --- a/src/request.c +++ b/src/request.c @@ -765,7 +765,10 @@ scan_options (RECODE_REQUEST request) scan_identifier (request); ALLOC (copy, strlen (request->scanned_string) + 1, char); if (!copy) - break; /* FIXME: should interrupt decoding */ + { + free (new); + break; /* FIXME: should interrupt decoding */ + } strcpy (copy, request->scanned_string); new_->option = copy; -- 2.40.0