summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2024-03-03 15:13:27 -0500
committerThomas E. Dickey <dickey@invisible-island.net>2024-03-04 03:38:38 -0500
commitd33708e30f102f6ab278d6f809eeaa18e65d0716 (patch)
treeea4613dafa94bf7770954944668e6af2e65e4ab1
parent9aba0a9212e0bb3ad010fff569bce95c20c3ebfa (diff)
scan-build(clang-17) reports possible null dereference, add checks
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r--src/Actions.c2
-rw-r--r--src/TextAction.c14
2 files changed, 12 insertions, 4 deletions
diff --git a/src/Actions.c b/src/Actions.c
index 0432627..8f0cead 100644
--- a/src/Actions.c
+++ b/src/Actions.c
@@ -918,7 +918,7 @@ XawDeclareActionVar(XawActionVarList *list, String name, String value)
{
String val = escape ? escape : value;
- if (strcmp(XrmQuarkToString(variable->qvalue), val) == 0)
+ if (val != NULL && strcmp(XrmQuarkToString(variable->qvalue), val) == 0)
{
if (escape)
XtFree(escape);
diff --git a/src/TextAction.c b/src/TextAction.c
index 254a785..09e22f2 100644
--- a/src/TextAction.c
+++ b/src/TextAction.c
@@ -1295,14 +1295,22 @@ _DeleteOrKill(TextWidget ctx, XawTextPosition from, XawTextPosition to,
else {
salt->contents = XtMalloc((Cardinal)(length + size + 1));
if (from >= old_from) {
- strncpy(salt->contents, ring, (size_t)size);
- salt->contents[size] = '\0';
+ if (ring != NULL) {
+ strncpy(salt->contents, ring, (size_t)size);
+ salt->contents[size] = '\0';
+ } else {
+ salt->contents[size = 0] = '\0';
+ }
strncat(salt->contents, string, (size_t)length);
}
else {
strncpy(salt->contents, string, (size_t)length);
salt->contents[length] = '\0';
- strncat(salt->contents, ring, (size_t)size);
+ if (ring != NULL) {
+ strncat(salt->contents, ring, (size_t)size);
+ } else {
+ size = 0;
+ }
}
salt->contents[length + size] = '\0';
XtFree(ring);