From e0ce64e11c0ad11a687c21f799e6aba952c19381 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 30 Jan 2019 15:42:20 +0100 Subject: [PATCH] #3937 libecl : Workaround to avoid crash for some summary files --- ThirdParty/Ert/lib/ecl/ecl_smspec.cpp | 11 +++++++---- ThirdParty/Ert/lib/util/hash.cpp | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp index f49f4e7b6b..a5611ce938 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp @@ -844,11 +844,14 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp hash_insert_ref( ecl_smspec->field_var_index , keyword , smspec_node ); break; case(ECL_SMSPEC_GROUP_VAR): - if (!hash_has_key(ecl_smspec->group_var_index , group)) - hash_insert_hash_owned_ref(ecl_smspec->group_var_index , group, hash_alloc() , hash_free__); + if (group) { - hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->group_var_index , group); - hash_insert_ref(var_hash , keyword , smspec_node ); + if (!hash_has_key(ecl_smspec->group_var_index , group)) + hash_insert_hash_owned_ref(ecl_smspec->group_var_index , group, hash_alloc() , hash_free__); + { + hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->group_var_index , group); + hash_insert_ref(var_hash , keyword , smspec_node ); + } } break; case(ECL_SMSPEC_REGION_VAR): diff --git a/ThirdParty/Ert/lib/util/hash.cpp b/ThirdParty/Ert/lib/util/hash.cpp index 05c5a1962e..a085abe6b9 100644 --- a/ThirdParty/Ert/lib/util/hash.cpp +++ b/ThirdParty/Ert/lib/util/hash.cpp @@ -82,6 +82,11 @@ static void * __hash_get_node(const hash_type *__hash , const char *key, bool ab hash_type * hash = (hash_type *) __hash; /* The net effect is no change - but .... ?? */ hash_node_type * node = NULL; { + if (key == NULL) + { + return NULL; + } + const uint32_t global_index = hash->hashf(key , strlen(key)); const uint32_t table_index = (global_index % hash->size);