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.fill.dir: avoid null pointer dereferences #5422

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nilason
Copy link
Contributor

@nilason nilason commented Mar 21, 2025

This most likely addresses a false positive static analyser issue, which was raised after merge of 9fdce5a.

But it doesn't hurt to add this simple check either.

*** CID 1593959:  Null pointer dereferences  (FORWARD_NULL)
/raster/r.fill.dir/ppupdate.c: 165 in ppupdate()
159     
160             n = list[i].next;
161             if (list[n].next == i) {
162                 /* we have a pair */
163                 /* find out how large the elevation difference would be for a change
164                  * in each basin */
   CID 1593959:  Null pointer dereferences  (FORWARD_NULL)
   Passing null pointer "that_elev" to "memcpy", which dereferences it.
165                 memcpy(that_elev, list[n].pp_alt, bpe());
166                 diff(that_elev, list[n].pp);
167     
168                 memcpy(this_elev, list[i].pp_alt, bpe());
169                 diff(this_elev, list[i].pp);
170     

** CID 1593958:  Null pointer dereferences  (FORWARD_NULL)
/raster/r.fill.dir/ppupdate.c: 168 in ppupdate()


________________________________________________________________________________________________________
*** CID 1593958:  Null pointer dereferences  (FORWARD_NULL)
/raster/r.fill.dir/ppupdate.c: 168 in ppupdate()
162                 /* we have a pair */
163                 /* find out how large the elevation difference would be for a change
164                  * in each basin */
165                 memcpy(that_elev, list[n].pp_alt, bpe());
166                 diff(that_elev, list[n].pp);
167     
   CID 1593958:  Null pointer dereferences  (FORWARD_NULL)
   Passing null pointer "this_elev" to "memcpy", which dereferences it.
168                 memcpy(this_elev, list[i].pp_alt, bpe());
169                 diff(this_elev, list[i].pp);
170     
171                 /* switch pour points in the basin where it makes the smallest
172                  * change */
173                 if (get_min(this_elev, that_elev) == this_elev) {

@nilason nilason added this to the 8.5.0 milestone Mar 21, 2025
@github-actions github-actions bot added raster Related to raster data processing C Related code is in C module labels Mar 21, 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 module raster Related to raster data processing
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant