mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
EGL: use unused 'n' argument for storing the config count (fixes #7953)
The 'n' argument was probably intended for the count, but it was unused. The Wayland platform would check whether n would be non-zero (and wouldn't initialize n with zero), so it would only succeed because it was initialized with random garbage. Pointy hat: @Sunderland93
This commit is contained in:
parent
b52a5ae664
commit
3ab7e780d1
@ -330,12 +330,11 @@ bool egl_init_context(egl_ctx_data_t *egl,
|
|||||||
EGLenum platform,
|
EGLenum platform,
|
||||||
void *display_data,
|
void *display_data,
|
||||||
EGLint *major, EGLint *minor,
|
EGLint *major, EGLint *minor,
|
||||||
EGLint *n, const EGLint *attrib_ptr,
|
EGLint *count, const EGLint *attrib_ptr,
|
||||||
egl_accept_config_cb_t cb)
|
egl_accept_config_cb_t cb)
|
||||||
{
|
{
|
||||||
EGLint i;
|
EGLint i;
|
||||||
EGLConfig *configs = NULL;
|
EGLConfig *configs = NULL;
|
||||||
EGLint count = 0;
|
|
||||||
EGLint matched = 0;
|
EGLint matched = 0;
|
||||||
int config_index = -1;
|
int config_index = -1;
|
||||||
EGLDisplay dpy = get_egl_display(platform, display_data);
|
EGLDisplay dpy = get_egl_display(platform, display_data);
|
||||||
@ -353,24 +352,24 @@ bool egl_init_context(egl_ctx_data_t *egl,
|
|||||||
|
|
||||||
RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor);
|
RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor);
|
||||||
|
|
||||||
if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1)
|
if (!eglGetConfigs(egl->dpy, NULL, 0, count) || *count < 1)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[EGL]: No configs to choose from.\n");
|
RARCH_ERR("[EGL]: No configs to choose from.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
configs = malloc(count * sizeof(*configs));
|
configs = malloc(*count * sizeof(*configs));
|
||||||
if (!configs)
|
if (!configs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!eglChooseConfig(egl->dpy, attrib_ptr,
|
if (!eglChooseConfig(egl->dpy, attrib_ptr,
|
||||||
configs, count, &matched) || !matched)
|
configs, *count, &matched) || !matched)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n");
|
RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < *count; i++)
|
||||||
{
|
{
|
||||||
if (!cb || cb(display_data, egl->dpy, configs[i]))
|
if (!cb || cb(display_data, egl->dpy, configs[i]))
|
||||||
{
|
{
|
||||||
@ -381,7 +380,7 @@ bool egl_init_context(egl_ctx_data_t *egl,
|
|||||||
|
|
||||||
free(configs);
|
free(configs);
|
||||||
|
|
||||||
if (i == count)
|
if (i == *count)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n");
|
RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user