Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/vector/Vlib: Fix Resource Leak issue in copy.c #4533

Merged
merged 12 commits into from
Oct 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/vector/Vlib/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ int Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out,
if (ret == -1) {
G_warning(_("Unable to add database link for vector map <%s>"),
Out->name);
Vect_destroy_field_info(Fi);
nilason marked this conversation as resolved.
Show resolved Hide resolved
return -1;
}

Expand All @@ -770,6 +771,7 @@ int Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out,
Fin->table, key, cats, ncats);
if (ret == DB_FAILED) {
G_warning(_("Unable to copy table <%s>"), Fin->table);
Vect_destroy_field_info(Fi);
return -1;
}

Expand All @@ -779,22 +781,26 @@ int Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out,
if (!driver) {
G_warning(_("Unable to open database <%s> with driver <%s>"),
Fin->database, Fin->driver);
Vect_destroy_field_info(Fi);
return -1;
}

/* do not allow duplicate keys */
if (db_create_index2(driver, Fin->table, Fi->key) != DB_OK) {
G_warning(_("Unable to create index"));
Vect_destroy_field_info(Fi);
return -1;
}

if (db_grant_on_table(driver, Fin->table, DB_PRIV_SELECT,
DB_GROUP | DB_PUBLIC) != DB_OK) {
G_warning(_("Unable to grant privileges on table <%s>"), Fin->table);
Vect_destroy_field_info(Fi);
return -1;
}

db_close_database_shutdown_driver(driver);
Vect_destroy_field_info(Fi);

return 0;
}
Loading