Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Fix some query segfaults
Browse files Browse the repository at this point in the history
 - A dataset loading failure would still allow the user to run queries;
 - Queries with invalid arguments would fail to be freed in interactive
   mode;
  • Loading branch information
voidbert committed Feb 17, 2024
1 parent 1b611e7 commit d1463f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions trabalho-pratico/src/interactive_mode/interactive_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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!");
}
Expand Down
2 changes: 1 addition & 1 deletion trabalho-pratico/src/queries/query_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d1463f3

Please sign in to comment.