summaryrefslogtreecommitdiff
path: root/src/TMparse.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>2019-04-11 17:26:58 +0200
committerThomas E. Dickey <dickey@his.com>2019-04-22 00:16:46 +0000
commitbca67f981dd3bcf730ac3816836b66049dd09f33 (patch)
treedc049616276d529589d06cf4e4f0a8aacd33aceb /src/TMparse.c
parent64dcec64b294d67a45596d84f91c876f15a5d95f (diff)
Fix leaks detected by covscan
The following leaks are reported by covscan: Error: RESOURCE_LEAK (CWE-772): libXt-20190411/src/ResConfig.c:542: alloc_arg: "_get_part" allocates memory that is stored into "part". libXt-20190411/src/ResConfig.c:544: noescape: Resource "part" is not freed or pointed-to in "_match_resource_to_widget". libXt-20190411/src/ResConfig.c:560: leaked_storage: Variable "part" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): libXt-20190411/src/TMgrab.c:108: alloc_arg: "XtKeysymToKeycodeList" allocates memory that is stored into "keycodes". libXt-20190411/src/TMgrab.c:115: var_assign: Assigning: "keycodeP" = "keycodes". libXt-20190411/src/TMgrab.c:124: leaked_storage: Variable "keycodeP" going out of scope leaks the storage it points to. libXt-20190411/src/TMgrab.c:124: leaked_storage: Variable "keycodes" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): libXt-20190411/src/TMparse.c:1544: alloc_fn: Storage is returned from allocation function "XtMalloc". libXt-20190411/src/TMparse.c:1544: var_assign: Assigning: "event" = storage returned from "XtMalloc(88U)". libXt-20190411/src/TMparse.c:1549: noescape: Resource "event" is not freed or pointed-to in "ParseQuotedStringEvent". libXt-20190411/src/TMparse.c:1555: leaked_storage: Variable "event" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): libXt-20190411/src/TMparse.c:1779: alloc_fn: Storage is returned from allocation function "XtMalloc". libXt-20190411/src/TMparse.c:1779: var_assign: Assigning: "action" = storage returned from "XtMalloc(32U)". libXt-20190411/src/TMparse.c:1784: noescape: Resource "action" is not freed or pointed-to in "ParseAction". libXt-20190411/src/TMparse.c:1785: leaked_storage: Variable "action" going out of scope leaks the storage it points to. In addition to this legitimate leaks, covscan can get confused by the allocated memory in XtKeysymToKeycodeList: Error: RESOURCE_LEAK (CWE-772): libXt-20190411/src/TMgrab.c:108: alloc_arg: "XtKeysymToKeycodeList" allocates memory that is stored into "keycodes". libXt-20190411/src/TMgrab.c:114: leaked_storage: Variable "keycodes" going out of scope leaks the storage it points to. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'src/TMparse.c')
-rw-r--r--src/TMparse.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/TMparse.c b/src/TMparse.c
index 0076d57..d0c8ce7 100644
--- a/src/TMparse.c
+++ b/src/TMparse.c
@@ -1554,6 +1554,7 @@ static String ParseEventSeq(
XtCXtToolkitError,
"... probably due to non-Latin1 character in quoted string",
(String*)NULL, (Cardinal*)NULL);
+ XtFree((char *)event);
return PanicModeRecovery(str);
}
*nextEvent = event;
@@ -1784,7 +1785,10 @@ static String ParseActionSeq(
action->next = NULL;
str = ParseAction(str, action, &quark, error);
- if (*error) return PanicModeRecovery(str);
+ if (*error) {
+ XtFree((char *)action);
+ return PanicModeRecovery(str);
+ }
action->idx = _XtGetQuarkIndex(parseTree, quark);
ScanWhitespace(str);