diff options
Diffstat (limited to 'src/Display.c')
-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]) { |