Skip to content

lib/imagery: Fix Resource Leak Issue in iscatt_core.c #6102

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 5 commits into
base: main
Choose a base branch
from

Conversation

ShubhamDesai
Copy link
Contributor

This pull request fixes issue identified by Coverity Scan ( CID : 1208098, 1208099, 1208100, 1543965, 1543972, 1543985, 1543987, 1543988, 1543989)

@github-actions github-actions bot added C Related code is in C libraries imagery labels Jul 22, 2025
ShubhamDesai and others added 4 commits July 22, 2025 15:53
@@ -102,6 +102,7 @@ int I_create_cat_rast(struct Cell_head *cat_rast_region, const char *cat_rast)
}

fclose(f_cat_rast);
G_free(row_data);
Copy link
Contributor

Choose a reason for hiding this comment

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

row_data needs to be freed before return on L100 too.

@@ -712,9 +717,12 @@ int I_compute_scatts(struct Cell_head *region, struct scCats *scatt_conds,
for (i_band = 0; i_band < n_bands; i_band++)
bands_ids[i_band] = -1;

if (n_bands != scatts->n_bands || n_bands != scatt_conds->n_bands)
if (n_bands != scatts->n_bands || n_bands != scatt_conds->n_bands) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This if statement can be moved to the top of the function, before any mallocs. Then there will be no need for unnecessary mallocs and frees.

@nilason nilason added this to the 8.5.0 milestone Jul 24, 2025
@github-project-automation github-project-automation bot moved this to In Progress in GRASS GIS Security Jul 24, 2025
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 imagery libraries
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants