Skip to content

Commit

Permalink
r3.showdspf: fix null pointer dereference
Browse files Browse the repository at this point in the history
In the current execution, when we face an error while trying
to open a database file, as part of error log we are dereferencing
a NULL file pointer (which is returend when we try to open a file).
Ideally we should be printing the name of the database file rather
than the file pointer. This fixes the problem of null pointer
dereference. Found via cppcheck tool.

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
  • Loading branch information
ymdatta committed Aug 28, 2024
1 parent b794d95 commit 755cdc4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions raster3d/r3.showdspf/main_ogl.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ int main(int argc, char **argv)
G_fatal_error(buff);
}
if ((Headfax.dspfinfp = G_fopen_old(buff, dsp, mapset)) == NULL) {
fprintf(stderr, "Unable to open <%s> for reading\n",
Headfax.dspfinfp);
fprintf(stderr, "Unable to open <%s> for reading\n", dsp);
exit(EXIT_FAILURE);
}

Expand Down

0 comments on commit 755cdc4

Please sign in to comment.