Skip to content

lib/vector/Vlib: Fix Resource Leak Issue in dbcolumns.c #5915

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ShubhamDesai
Copy link
Contributor

This pull request fixes issue identified by coverity scan (CID : 1207742, 1207743, 1207745, 1207746, 1207748, 1207749)
Used Vect_destroy_field_info( ); db_close_database_shutdown_driver( ); to fix this issue.

@github-actions github-actions bot added vector Related to vector data processing C Related code is in C libraries labels Jun 19, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@nilason nilason added this to the 8.5.0 milestone Jun 23, 2025
@github-project-automation github-project-automation bot moved this to In Progress in GRASS GIS Security Jun 23, 2025
if (db_open_database(driver, &handle) != DB_OK)
return (NULL);
if (db_open_database(driver, &handle) != DB_OK) {
goto cleanup;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we only need to shutdown driver and free fi (open database just failed!).

@@ -74,8 +78,9 @@ const char *Vect_get_column_names(struct Map_info *Map, int field)
G_free(col_names);
G_debug(3, "%s", list);

db_close_database(driver);
db_shutdown_driver(driver);
cleanup:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup_exit

if (db_open_database(driver, &handle) != DB_OK)
return (NULL);
if (db_open_database(driver, &handle) != DB_OK) {
goto cleanup;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we only need to shutdown driver and free fi (open database just failed!).

@@ -130,8 +139,9 @@ const char *Vect_get_column_types(struct Map_info *Map, int field)
G_free(sqltype_names);
G_debug(3, "%s", list);

db_close_database(driver);
db_shutdown_driver(driver);
cleanup:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note above.

if (db_open_database(driver, &handle) != DB_OK)
return (NULL);
if (db_open_database(driver, &handle) != DB_OK) {
goto cleanup;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issues for Vect_get_column_names_types as for the other two function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C libraries vector Related to vector data processing
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants