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

r.horizon: address coverity scan 'Null pointer dereferences' #3620

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

petrasovaa
Copy link
Contributor

This should address this (I think)

*** CID 1543994:  Null pointer dereferences  (REVERSE_INULL)
/raster/r.horizon/main.c: 1274 in calculate_raster_mode()
1268             Rast_append_format_history(
1269                 &history,
1270                 "Horizon view from azimuth angle %.2f degrees CCW from East",
1271                 angle * rad2deg);
1272     
1273             Rast_write_history(shad_filename, &history);
>>>     CID 1543994:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "shad_filename" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
1274             if (shad_filename)
1275                 G_free(shad_filename);
1276         }

@petrasovaa petrasovaa added this to the 8.4.0 milestone Apr 17, 2024
@petrasovaa petrasovaa requested a review from nilason April 17, 2024 14:23
@petrasovaa petrasovaa self-assigned this Apr 17, 2024
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.

I believe this should do it, shad_filename was never freed after its allocation. Even if it happened to be still NULL then free() wouldn't do anything.

@github-actions github-actions bot added raster Related to raster data processing C Related code is in C module labels Apr 17, 2024
@petrasovaa petrasovaa enabled auto-merge (squash) April 17, 2024 15:15
@petrasovaa petrasovaa merged commit 2d982f1 into OSGeo:main Apr 17, 2024
26 checks passed
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 raster Related to raster data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants