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

ps.map: Initialize variable before using it in conditional #4286

Merged
merged 1 commit into from
Sep 7, 2024

Conversation

ymdatta
Copy link
Contributor

@ymdatta ymdatta commented Sep 6, 2024

Currently, cats_ok variable is only set when do_raster is true in post script structure. Variable can be filled with any value as it it uninitiazlied which can lead to unpredictable behavior. Set the value to 0 indicating error by default.

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, `cats_ok` variable is only set when `do_raster` is
true in post script structure. Variable can be filled with any
value as it it uninitiazlied which can lead to unpredictable
behavior. Set the value to 0 indicating error by default.

This was found using cppcheck tool.

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
@github-actions github-actions bot added C Related code is in C module labels Sep 6, 2024
@echoix echoix merged commit 9bbfd6b into OSGeo:main Sep 7, 2024
26 checks passed
@neteler neteler added this to the 8.5.0 milestone Sep 7, 2024
Mahesh1998 pushed a commit to Mahesh1998/grass that referenced this pull request Sep 19, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants