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;
|
int i;
|
||||||
SDL_DisplayID *displays;
|
SDL_DisplayID *displays;
|
||||||
|
|
||||||
|
if (!_this) {
|
||||||
|
if (count) {
|
||||||
|
*count = 0;
|
||||||
|
}
|
||||||
|
return SDL_UninitializedVideo();
|
||||||
|
}
|
||||||
|
|
||||||
displays = (SDL_DisplayID *)SDL_malloc((_this->num_displays + 1) * sizeof(*displays));
|
displays = (SDL_DisplayID *)SDL_malloc((_this->num_displays + 1) * sizeof(*displays));
|
||||||
if (displays) {
|
if (displays) {
|
||||||
if (count) {
|
if (count) {
|
||||||
@@ -794,8 +801,7 @@ int SDL_GetDisplayIndex(SDL_DisplayID displayID)
|
|||||||
int display_index;
|
int display_index;
|
||||||
|
|
||||||
if (!_this) {
|
if (!_this) {
|
||||||
SDL_UninitializedVideo();
|
return SDL_UninitializedVideo();
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (display_index = 0; display_index < _this->num_displays; ++display_index) {
|
for (display_index = 0; display_index < _this->num_displays; ++display_index) {
|
||||||
|
Reference in New Issue
Block a user