mirror of
https://github.com/X11Libre/xserver.git
synced 2026-11-08 04:16:22 +00:00
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:
parent
a7f884f66e
commit
df6dd17bf9
1 changed files with 8 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue