summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2019-11-15 21:00:44 -0500
committerThomas E. Dickey <dickey@invisible-island.net>2019-11-15 21:02:36 -0500
commit51cbf52b7668ad46a428dabe8e79e6819e825b20 (patch)
tree50db635d2597ca249145395ae4cea3c2457c436c
parent1bf4dfce4431b016a2970e195ea55188288264f6 (diff)
add a null-pointer check, overlooked in fix for issue #12.
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r--src/Display.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/Display.c b/src/Display.c
index f256918..cff344c 100644
--- a/src/Display.c
+++ b/src/Display.c
@@ -274,18 +274,20 @@ XtOpenDisplay(XtAppContext app,
&language : NULL));
UNLOCK_PROCESS;
d = XOpenDisplay(displayName);
- if (ScreenCount(d) <= 0) {
- XtErrorMsg("nullDisplay",
- THIS_FUNC, XtCXtToolkitError,
- THIS_FUNC " requires a non-NULL display",
- NULL, NULL);
- }
- if (DefaultScreen(d) < 0 || DefaultScreen(d) >= ScreenCount(d)) {
- XtWarningMsg("nullDisplay",
- THIS_FUNC, XtCXtToolkitError,
- THIS_FUNC " default screen is invalid (ignoring)",
- NULL, NULL);
- DefaultScreen(d) = 0;
+ if (d != NULL) {
+ if (ScreenCount(d) <= 0) {
+ XtErrorMsg("nullDisplay",
+ THIS_FUNC, XtCXtToolkitError,
+ THIS_FUNC " requires a non-NULL display",
+ NULL, NULL);
+ }
+ if (DefaultScreen(d) < 0 || DefaultScreen(d) >= ScreenCount(d)) {
+ XtWarningMsg("nullDisplay",
+ THIS_FUNC, XtCXtToolkitError,
+ THIS_FUNC " default screen is invalid (ignoring)",
+ NULL, NULL);
+ DefaultScreen(d) = 0;
+ }
}
if (!applName && !(applName = getenv("RESOURCE_NAME"))) {