Skip to content

Commit 1cf6c53

Browse files
committed
gfx/egl: plug configs leak on no-matching-attributes failure path in egl_init_context_common
egl_init_context_common malloc()s an EGLConfig array to pass to _egl_choose_config, then iterates it to find a caller-accepted config. On the normal failure-to-find path (i == *count) the function correctly free()s the array before returning false. The error path immediately above it - when _egl_choose_config itself fails or returns matched == 0 - skipped that free: if (!_egl_choose_config(egl->dpy, attrib_ptr, configs, *count, &matched) || !matched) { RARCH_ERR("[EGL] No EGL configs with appropriate attributes.\n"); return false; /* leaks 'configs' */ } The allocation can be sizeable on systems advertising many configs (typical count 10-50, typical sizeof(EGLConfig) is a pointer), so this is tens to hundreds of bytes per failed init attempt. The leak is persistent across repeated attempts - if a GL driver reinits after a display mode change and this path trips each time, it accumulates. Fix: add the free(configs) before the return false, matching the successful-no-candidate path further down. One-line change. Thread-safety: unchanged. egl_init_context_common runs on the video thread (or main thread when threaded video is off); the configs array is a local.
1 parent 7ac1583 commit 1cf6c53

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

gfx/common/egl_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ bool egl_init_context_common(
581581
configs, *count, &matched) || !matched)
582582
{
583583
RARCH_ERR("[EGL] No EGL configs with appropriate attributes.\n");
584+
free(configs);
584585
return false;
585586
}
586587

0 commit comments

Comments
 (0)