mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
Fixed crash if a display is enumerated twice
This can happen if a monitor is in the process of becoming primary because another monitor was disconnected.
This commit is contained in:
@@ -357,10 +357,19 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
|
||||
SDL_bool moved = (index != i);
|
||||
SDL_bool changed_bounds = SDL_FALSE;
|
||||
|
||||
if (driverdata->state != DisplayRemoved) {
|
||||
/* We've already enumerated this display, don't move it */
|
||||
return;
|
||||
}
|
||||
|
||||
if (index >= _this->num_displays) {
|
||||
/* This should never happen due to the check above, but just in case... */
|
||||
return;
|
||||
}
|
||||
|
||||
if (moved) {
|
||||
SDL_VideoDisplay tmp;
|
||||
|
||||
SDL_assert(index < _this->num_displays);
|
||||
SDL_memcpy(&tmp, &_this->displays[index], sizeof(tmp));
|
||||
SDL_memcpy(&_this->displays[index], &_this->displays[i], sizeof(tmp));
|
||||
SDL_memcpy(&_this->displays[i], &tmp, sizeof(tmp));
|
||||
|
Reference in New Issue
Block a user