mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
Fixed crash if SDL_GetDisplays() is called before video is initialized
This commit is contained in:
@@ -744,6 +744,13 @@ SDL_DisplayID *SDL_GetDisplays(int *count)
|
||||
int i;
|
||||
SDL_DisplayID *displays;
|
||||
|
||||
if (!_this) {
|
||||
if (count) {
|
||||
*count = 0;
|
||||
}
|
||||
return SDL_UninitializedVideo();
|
||||
}
|
||||
|
||||
displays = (SDL_DisplayID *)SDL_malloc((_this->num_displays + 1) * sizeof(*displays));
|
||||
if (displays) {
|
||||
if (count) {
|
||||
@@ -794,8 +801,7 @@ int SDL_GetDisplayIndex(SDL_DisplayID displayID)
|
||||
int display_index;
|
||||
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return -1;
|
||||
return SDL_UninitializedVideo();
|
||||
}
|
||||
|
||||
for (display_index = 0; display_index < _this->num_displays; ++display_index) {
|
||||
|
Reference in New Issue
Block a user