egl: Check for a NULL pointer in SDL_EGL_GetProcAddress.

This happens on kmsdrm if you try to GetProcAddress before creating
a window.

Fixes #5399.
This commit is contained in:
Ryan C. Gordon 2022-11-15 13:57:01 -05:00
parent f3cc99fb93
commit 44d7b8b91d
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 19 additions and 18 deletions

View File

@ -244,9 +244,10 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext
void * void *
SDL_EGL_GetProcAddress(_THIS, const char *proc) SDL_EGL_GetProcAddress(_THIS, const char *proc)
{ {
void *retval = NULL;
if (_this->egl_data != NULL) {
const Uint32 eglver = (((Uint32) _this->egl_data->egl_version_major) << 16) | ((Uint32) _this->egl_data->egl_version_minor); const Uint32 eglver = (((Uint32) _this->egl_data->egl_version_major) << 16) | ((Uint32) _this->egl_data->egl_version_minor);
const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32) 1) << 16) | 5); const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32) 1) << 16) | 5);
void *retval = NULL;
/* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */ /* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */
if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
@ -264,7 +265,7 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc)
if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
retval = _this->egl_data->eglGetProcAddress(proc); retval = _this->egl_data->eglGetProcAddress(proc);
} }
}
return retval; return retval;
} }