summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-07-28 16:18:02 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-07-28 16:18:02 -0700
commited190ca257c808b5d76babf01a5dd57c7d749c9d (patch)
tree119e44a53c8ec081ca6a1f021ac156042fc04adf
parent75a78342999f5c98ba5e0d154a1c506497daac5d (diff)
ClearFontStuff: avoid NULL pointer dereference
Clears warning from cppcheck: psgeom.c:400:5: warning: Either the condition 'stuff' is redundant or there is possible null pointer dereference: stuff. [nullPointerRedundantCheck] bzero(stuff, sizeof(FontStuff)); ^ psgeom.c:398:9: note: Assuming that condition 'stuff' is not redundant if (stuff && stuff->foundry) ^ psgeom.c:400:5: note: Null pointer dereference bzero(stuff, sizeof(FontStuff)); ^ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/app/xkbprint/-/merge_requests/6>
-rw-r--r--psgeom.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/psgeom.c b/psgeom.c
index 33d3534..627d401 100644
--- a/psgeom.c
+++ b/psgeom.c
@@ -395,9 +395,10 @@ typedef struct {
static void
ClearFontStuff(FontStuff *stuff)
{
- if (stuff && stuff->foundry)
+ if (stuff) {
free(stuff->foundry);
- bzero(stuff, sizeof(FontStuff));
+ bzero(stuff, sizeof(FontStuff));
+ }
return;
}