Skip to content

v.label.sa: Fix Resource Leak issue in labels.c #5967

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

Conversation

ShubhamDesai
Copy link
Contributor

This pull request fixes issue identified by Coverity Scan(CID : 1415681, 1415703, 1415745, 1415754)
Used Vect_destroy_field_info(), G_free(), Vect_destroy_list() to fix this issue

@github-actions github-actions bot added vector Related to vector data processing C Related code is in C module labels Jun 25, 2025
@nilason nilason added this to the 8.5.0 milestone Jul 2, 2025
@github-project-automation github-project-automation bot moved this to In Progress in GRASS GIS Security Jul 2, 2025
Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

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

Looks good so far. There remains a single issue for the v.label.sa module in the file font.c, please address that one here too.

@ShubhamDesai
Copy link
Contributor Author

Looks good so far. There remains a single issue for the v.label.sa module in the file font.c, please address that one here too.

done.
Updated the loop so that as soon as we hit the first matching entry we call G_malloc() once, populate the struct fields using font_cap->… instead of font_cap[fonts_count] (because font_cap points to a single GFONT_CAP, not an array, and -> safely dereferences that one object), and immediately break; out of the loop—this guarantees exactly one allocation per call, removes any chance of overwriting (and leaking) a previous pointer, fixes the undefined‐behavior of array‐style indexing on a lone allocation.

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 module vector Related to vector data processing
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants