Commit 1cf6c53
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| 584 | + | |
584 | 585 | | |
585 | 586 | | |
586 | 587 | | |
| |||
0 commit comments