diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2019-11-09 21:01:29 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2019-11-09 21:01:29 -0500 |
commit | 1bf4dfce4431b016a2970e195ea55188288264f6 (patch) | |
tree | cf65666adb371976ee430a7a7482761cbd800886 /src | |
parent | c7bdc7c0b75b6ec4df0bc180a20cf55ed0f43281 (diff) |
issue #12: work within existing interface which attempts to obtain the
display-pointer from the screen-pointer but fails when the screen-pointer
itself is invalid. Ensure that the screen-pointer is valid by checking
the default_screen value against the valid range, and forcing it to zero
if it is out of bounds.
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/Display.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Display.c b/src/Display.c index 0bfaac9..f256918 100644 --- a/src/Display.c +++ b/src/Display.c @@ -249,6 +249,7 @@ InitPerDisplay(Display *dpy, return pd; } +#define THIS_FUNC "XtOpenDisplay" Display * XtOpenDisplay(XtAppContext app, _Xconst _XtString displayName, @@ -273,6 +274,19 @@ 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 (!applName && !(applName = getenv("RESOURCE_NAME"))) { if (*argc > 0 && argv[0] && *argv[0]) { |