ソースを参照

Fixed crash if initialization of EGL failed but was tried again later.

The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
Philipp Wiesemann 9 年 前
コミット
0e45984fa0
1 ファイル変更5 行追加0 行削除
  1. 5 0
      src/video/SDL_egl.c

+ 5 - 0
src/video/SDL_egl.c

@@ -65,6 +65,7 @@
 _this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
 if (!_this->egl_data->NAME) \
 { \
+    SDL_EGL_UnloadLibrary(_this); \
     return SDL_SetError("Could not retrieve EGL function " #NAME); \
 }
     
@@ -214,6 +215,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
     _this->egl_data->egl_dll_handle = egl_dll_handle;
 
     if (egl_dll_handle == NULL) {
+        SDL_EGL_UnloadLibrary(_this);
         return SDL_SetError("Could not initialize OpenGL / GLES library");
     }
 
@@ -235,6 +237,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
             if (dll_handle != NULL) {
                 SDL_UnloadObject(dll_handle);
             }
+            SDL_EGL_UnloadLibrary(_this);
             return SDL_SetError("Could not load EGL library");
         }
         SDL_ClearError();
@@ -264,10 +267,12 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
 #if !defined(__WINRT__)
     _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display);
     if (!_this->egl_data->egl_display) {
+        SDL_EGL_UnloadLibrary(_this);
         return SDL_SetError("Could not get EGL display");
     }
     
     if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
+        SDL_EGL_UnloadLibrary(_this);
         return SDL_SetError("Could not initialize EGL");
     }
 #endif