summaryrefslogtreecommitdiff
path: root/src/ResConfig.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2019-05-16 20:53:42 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2019-05-18 06:42:03 -0400
commit1f0e3238352a497a59a36e0b8a5b4723c634b2e1 (patch)
treed49a598905cf10e28ff7d21a627e2f90a6e79ada /src/ResConfig.c
parentfb78a7c881adbe46f1f8c6e8e429bc8963c9b3e8 (diff)
fix most clang --analyze warnings about null-pointers
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src/ResConfig.c')
-rw-r--r--src/ResConfig.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/src/ResConfig.c b/src/ResConfig.c
index 03867d4..169b22f 100644
--- a/src/ResConfig.c
+++ b/src/ResConfig.c
@@ -118,10 +118,16 @@ _set_resource_values (
Display *dpy;
XrmDatabase tmp_db;
- if (!XtIsWidget (w))
- dpy = XtDisplay (w->core.parent);
- else
- dpy = XtDisplay (w);
+ if (last_part == NULL)
+ return;
+
+ if (!XtIsWidget (w)) {
+ if (w == 0 || w->core.parent == 0)
+ return;
+ dpy = XtDisplay (w->core.parent);
+ } else {
+ dpy = XtDisplay (w);
+ }
tmp_db = XtDatabase(dpy);
/*
@@ -714,33 +720,35 @@ _search_widget_tree (
* Parse last segment off of resource string, (eg. background, font,
* etc.)
*/
- last_token = _get_last_part (remainder, &last_part);
- /*
- * this case covers resources of only one level (eg. *background)
- */
- if (remainder[0] == 0) {
- _set_resource_values (w, resource, value, last_part);
- if (last_token == '*')
- _apply_values_to_children (parent, remainder, resource,
- value, last_token, last_part);
- /*
- * all other resource strings are recursively applied to the widget tree.
- * Prepend a '.' to the remainder string if there is no leading token.
- */
- } else {
- char *indx, *copy;
- if (remainder[0] != '*' && remainder[0] != '.') {
- XtAsprintf (&copy, ".%s", remainder);
- XtFree (remainder);
- remainder = copy;
- }
- indx = remainder;
- _set_and_search (parent, indx, remainder, resource, value,
- last_token, last_part);
+ if (remainder) {
+ last_token = _get_last_part (remainder, &last_part);
+ /*
+ * this case covers resources of only one level (eg. *background)
+ */
+ if (remainder[0] == 0) {
+ _set_resource_values (w, resource, value, last_part);
+ if (last_token == '*')
+ _apply_values_to_children (parent, remainder, resource,
+ value, last_token, last_part);
+ /*
+ * all other resource strings are recursively applied to the widget tree.
+ * Prepend a '.' to the remainder string if there is no leading token.
+ */
+ } else {
+ char *indx, *copy;
+ if (remainder[0] != '*' && remainder[0] != '.') {
+ XtAsprintf (&copy, ".%s", remainder);
+ XtFree (remainder);
+ remainder = copy;
+ }
+ indx = remainder;
+ _set_and_search (parent, indx, remainder, resource, value,
+ last_token, last_part);
+ }
+
+ XtFree (remainder);
+ XtFree (last_part);
}
-
- XtFree (remainder);
- XtFree (last_part);
}
/*