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

v.generalize: Initialize all of structure contents before using it #4281

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

ymdatta
Copy link
Contributor

@ymdatta ymdatta commented Sep 5, 2024

Currently, in head which is a POINT_LIST structure, we are only initializing the next pointer to NULL, but data present in the point substructure is not initialized which implies that it would be filled with random data. To avoid such scenario, initialize point coordinates to zero.

This was found using cppcheck tool.

Additional information:

  1. Machine used: Virtual Machine running Ubuntu 22.04.4 LTS.
  2. Reproduction rate: 100%, reproducible every time.
  3. Output from cppcheck prior to fix
image

After the fix

image

Currently, in `head` which is a `POINT_LIST` structure, we are
only initializing the next pointer to NULL, but data present
in the point substructure is not initialized which implies that
it would be filled with random data. To avoid such scenario,
initialize point coordinates to zero.

This was found using cppcheck tool.

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
@github-actions github-actions bot added vector Related to vector data processing C Related code is in C module labels Sep 5, 2024
@echoix
Copy link
Member

echoix commented Sep 5, 2024

If this pattern is correct to merge, I'll approve and merge #4282, as it's the same reasoning

vector/v.generalize/smoothing.c Outdated Show resolved Hide resolved
Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
@neteler neteler added this to the 8.5.0 milestone Sep 10, 2024
@echoix echoix merged commit 76507cc into OSGeo:main Sep 10, 2024
26 checks passed
Mahesh1998 pushed a commit to Mahesh1998/grass that referenced this pull request Sep 19, 2024
…SGeo#4281)

* v.generalize: Initialize all of structure contents before using it

Currently, in `head` which is a `POINT_LIST` structure, we are
only initializing the next pointer to NULL, but data present
in the point substructure is not initialized which implies that
it would be filled with random data. To avoid such scenario,
initialize point coordinates to zero.

This was found using cppcheck tool.

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>

* Use correct literal for double type

Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>

---------

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
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
None yet
Development

Successfully merging this pull request may close these issues.

4 participants