mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4172 libecl : Guard null pointer access
This commit is contained in:
parent
b120d0a2c1
commit
dfd4539786
34
ThirdParty/Ert/lib/ecl/ecl_smspec.cpp
vendored
34
ThirdParty/Ert/lib/ecl/ecl_smspec.cpp
vendored
@ -822,18 +822,21 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp
|
|||||||
|
|
||||||
switch(var_type) {
|
switch(var_type) {
|
||||||
case(ECL_SMSPEC_COMPLETION_VAR):
|
case(ECL_SMSPEC_COMPLETION_VAR):
|
||||||
/* Three level indexing: variable -> well -> string(cell_nr)*/
|
if (well)
|
||||||
if (!hash_has_key(ecl_smspec->well_completion_var_index , well))
|
|
||||||
hash_insert_hash_owned_ref(ecl_smspec->well_completion_var_index , well , hash_alloc() , hash_free__);
|
|
||||||
{
|
{
|
||||||
hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well);
|
/* Three level indexing: variable -> well -> string(cell_nr)*/
|
||||||
char cell_str[16];
|
if (!hash_has_key(ecl_smspec->well_completion_var_index , well))
|
||||||
sprintf(cell_str , "%d" , num);
|
hash_insert_hash_owned_ref(ecl_smspec->well_completion_var_index , well , hash_alloc() , hash_free__);
|
||||||
if (!hash_has_key(cell_hash , cell_str))
|
|
||||||
hash_insert_hash_owned_ref(cell_hash , cell_str , hash_alloc() , hash_free__);
|
|
||||||
{
|
{
|
||||||
hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str);
|
hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well);
|
||||||
hash_insert_ref(var_hash , keyword , smspec_node );
|
char cell_str[16];
|
||||||
|
sprintf(cell_str , "%d" , num);
|
||||||
|
if (!hash_has_key(cell_hash , cell_str))
|
||||||
|
hash_insert_hash_owned_ref(cell_hash , cell_str , hash_alloc() , hash_free__);
|
||||||
|
{
|
||||||
|
hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str);
|
||||||
|
hash_insert_ref(var_hash , keyword , smspec_node );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -866,11 +869,14 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp
|
|||||||
ecl_smspec->num_regions = util_int_max(ecl_smspec->num_regions , num);
|
ecl_smspec->num_regions = util_int_max(ecl_smspec->num_regions , num);
|
||||||
break;
|
break;
|
||||||
case (ECL_SMSPEC_WELL_VAR):
|
case (ECL_SMSPEC_WELL_VAR):
|
||||||
if (!hash_has_key(ecl_smspec->well_var_index , well))
|
if (well)
|
||||||
hash_insert_hash_owned_ref(ecl_smspec->well_var_index , well , hash_alloc() , hash_free__);
|
|
||||||
{
|
{
|
||||||
hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->well_var_index , well);
|
if (!hash_has_key(ecl_smspec->well_var_index , well))
|
||||||
hash_insert_ref(var_hash , keyword , smspec_node );
|
hash_insert_hash_owned_ref(ecl_smspec->well_var_index , well , hash_alloc() , hash_free__);
|
||||||
|
{
|
||||||
|
hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->well_var_index , well);
|
||||||
|
hash_insert_ref(var_hash , keyword , smspec_node );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(ECL_SMSPEC_MISC_VAR):
|
case(ECL_SMSPEC_MISC_VAR):
|
||||||
|
Loading…
Reference in New Issue
Block a user