diff --git a/trabalho-pratico/src/interactive_mode/interactive_mode.c b/trabalho-pratico/src/interactive_mode/interactive_mode.c index 2334f36..6afdb8e 100644 --- a/trabalho-pratico/src/interactive_mode/interactive_mode.c +++ b/trabalho-pratico/src/interactive_mode/interactive_mode.c @@ -82,6 +82,7 @@ void __interactive_mode_load_dataset(database_t **database) { *database = database_create(); if (!*database) { + *database = NULL; activity_messagebox_run("Failed to allocate new database!"); free(path); return; @@ -90,6 +91,8 @@ void __interactive_mode_load_dataset(database_t **database) { /* Load new dataset */ if (dataset_loader_load(*database, path, NULL, NULL)) { activity_messagebox_run("Failed to load dataset! Old data has been discarded."); + database_free(*database); + *database = NULL; } else { activity_messagebox_run("Dataset loaded successfully!"); } diff --git a/trabalho-pratico/src/queries/query_instance.c b/trabalho-pratico/src/queries/query_instance.c index fbd739d..69db9b4 100644 --- a/trabalho-pratico/src/queries/query_instance.c +++ b/trabalho-pratico/src/queries/query_instance.c @@ -123,7 +123,7 @@ const void *query_instance_get_argument_data(const query_instance_t *query) { } void query_instance_free(query_instance_t *query) { - if (query->type) { + if (query->type && query->argument_data) { const query_type_free_arguments_callback_t free_cb = query_type_get_free_arguments_callback(query->type); free_cb(query->argument_data);