xwin: catch potential realloc() failure winInitializeScreens()

In the unlikely case that realloc() fails on screen init, it's better
to have a decdent error message instead of just segfault.
(at that point we don't have any serious way for recovery anyways,
thus FatalError() is appropriate here)

X-Co-Slopped-By: BigPickle
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2026-06-08 16:52:47 +02:00 • committed by Enrico Weigelt
commit df6dd17bf9

View file

@ -177,9 +177,16 @@ winInitializeScreens(int maxscreens)
if (maxscreens > g_iNumScreens) {
/* Reallocate the memory for DDX-specific screen info */
g_ScreenInfo =
winScreenInfo *newScreenInfo =
realloc(g_ScreenInfo, maxscreens * sizeof(winScreenInfo));
if (!newScreenInfo) {
FatalError("winInitializeScreens: realloc(%p, %d) failed\n",
(void *)g_ScreenInfo, maxscreens * (int)sizeof(winScreenInfo));
return;
}
g_ScreenInfo = newScreenInfo;
/* Set default values for any new screens */
for (i = g_iNumScreens; i < maxscreens; i++)
winInitializeScreen(i);