ECC-1185: Crash in codes_context_delete() call (Part 1)

This commit is contained in:
Shahram Najm 2020-12-22 16:47:23 +00:00
parent 03ab8348ba
commit 7a14817017
10 changed files with 25 additions and 6 deletions

View File

@ -388,5 +388,6 @@ int main(int argc, char** argv)
}
codes_handle_delete(h);
grib_context_delete(grib_context_get_default());
return 0;
}

View File

@ -214,7 +214,12 @@ static void destroy(grib_context* context, grib_action* act)
grib_context_free_persistent(context, act->name);
grib_context_free_persistent(context, act->op);
grib_context_free_persistent(context, act->name_space);
if(act->name_space) {
grib_context_free_persistent(context, act->name_space);
}
if (act->set)
grib_context_free_persistent(context, act->set);
if (act->defaultkey) {
grib_context_free_persistent(context, act->defaultkey);
}
}

View File

@ -530,6 +530,7 @@ void grib_codetable_delete(grib_context* c)
for (i = 0; i < t->size; i++) {
grib_context_free_persistent(c, t->entries[i].abbreviation);
grib_context_free_persistent(c, t->entries[i].title);
grib_context_free_persistent(c, t->entries[i].units);
}
grib_context_free_persistent(c, t->filename[0]);
if (t->filename[1])

View File

@ -800,8 +800,16 @@ void grib_context_reset(grib_context* c)
grib_smart_table_delete(c);
c->smart_table = NULL;
if (c->grib_definition_files_dir)
grib_context_free(c, c->grib_definition_files_dir);
if (c->grib_definition_files_dir) {
grib_string_list* next = c->grib_definition_files_dir;
grib_string_list* cur = NULL;
while (next) {
cur = next;
next = next->next;
grib_context_free(c, cur->value);
grib_context_free(c, cur);
}
}
if (c->multi_support_on)
grib_multi_support_reset(c);
@ -813,7 +821,7 @@ void grib_context_delete(grib_context* c)
c = grib_context_get_default();
grib_hash_keys_delete(c->keys);
grib_trie_delete(c->def_files);
/*grib_trie_delete(c->def_files); TODO:masn */
grib_context_reset(c);
if (c != &default_grib_context)

View File

@ -55,5 +55,6 @@ int main(int argc, char** argv)
fclose(fp);
grib_context_delete(grib_context_get_default());
return 0;
}

View File

@ -52,5 +52,7 @@ int main(int argc, char* argv[])
codes_handle_delete(h);
}
fclose(in);
grib_context_delete(grib_context_get_default());
return 0;
}

View File

@ -121,5 +121,6 @@ int main(int argc, char** argv)
fclose(in);
}
grib_context_delete(grib_context_get_default());
return 0;
}

View File

@ -153,7 +153,7 @@ int main(int argc, char* argv[])
free(shortNames[i]);
free(shortNames);
/*grib_context_delete(grib_context_get_default());*/
grib_context_delete(grib_context_get_default());
return 0;
}

View File

@ -1,4 +1,3 @@
leak:process_elements
leak:tests/bufr_ecc-517.c
leak:src/action_class_rename.c
leak:tests/grib_indexing.c

View File

@ -78,5 +78,6 @@ int main(int argc, char* argv[])
count++;
}
grib_context_delete(grib_context_get_default());
return 0;
}