summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-05-07 10:20:30 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-05-07 11:21:03 -0700
commit49cec54165b46116c73e7db78c46b624948b01c8 (patch)
treebf26040f3da7f94c5cadca577d5158121b25488e
parent11384211b9407eeab475e54e4806e47825fb1790 (diff)
downloadxorg-lib-libXaw-49cec54165b46116c73e7db78c46b624948b01c8.tar.gz
Stop memory leak in error paths in XawTextSinkConvertPropertyList()
Fixes issues reported by Oracle Parfait static analyzer: Error: Memory leak Memory leak [memory-leak] (CWE 401): Memory leak of pointer pointer allocated with XtCalloc(1, 144) at line 1586 of lib/libXaw/src/TextSink.c in function 'XawTextSinkConvertPropertyList'. pointer allocated at line 1570 with XtCalloc(1, 144) pointer leaks when XawFindArgVal(params, "font") != NULL at line 1573 and argval->value != NULL at line 1574 and XLoadQueryFont(screen->display, argval->value) == NULL at line 1577. Memory leak [memory-leak] (CWE 401): Memory leak of pointer pointer allocated with XtCalloc(1, 144) at line 1605 of lib/libXaw/src/TextSink.c in function 'XawTextSinkConvertPropertyList'. pointer allocated at line 1570 with XtCalloc(1, 144) pointer leaks when argval->value == NULL at line 1574 and XawFindArgVal(params, "foreground") != NULL at line 1593 and argval->value != NULL at line 1594 and XAllocNamedColor(...) == 0 at line 1595. Memory leak [memory-leak] (CWE 401): Memory leak of pointer pointer allocated with XtCalloc(1, 144) at line 1622 of lib/libXaw/src/TextSink.c in function 'XawTextSinkConvertPropertyList'. pointer allocated at line 1570 with XtCalloc(1, 144) pointer leaks when argval->value == NULL at line 1574 and XawFindArgVal(params, "background") != NULL at line 1610 and argval->value != NULL at line 1611 and XAllocNamedColor(...) == 0 at line 1612. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/TextSink.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/TextSink.c b/src/TextSink.c
index d9e3f7b..3b43576 100644
--- a/src/TextSink.c
+++ b/src/TextSink.c
@@ -1583,6 +1583,7 @@ XawTextSinkConvertPropertyList(String name, String spec, Screen *screen,
if (prev)
prev->next = NULL;
XawFreeParamsStruct(params);
+ XtFree((char *)prop);
return (NULL);
}
prop->mask |= XAW_TPROP_FONT;
@@ -1602,6 +1603,7 @@ XawTextSinkConvertPropertyList(String name, String spec, Screen *screen,
if (prev)
prev->next = NULL;
XawFreeParamsStruct(params);
+ XtFree((char *)prop);
return (NULL);
}
prop->foreground = color.pixel;
@@ -1619,6 +1621,7 @@ XawTextSinkConvertPropertyList(String name, String spec, Screen *screen,
if (prev)
prev->next = NULL;
XawFreeParamsStruct(params);
+ XtFree((char *)prop);
return (NULL);
}
prop->background = color.pixel;