From 3f1055de94d1590dd79adc0e3d4a8067e016de38 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 17 Aug 2015 18:52:17 -0500 Subject: [PATCH] Fix a memory leak in the EGL GLInterface. --- Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp b/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp index 43678e1acc..1adbfb06c6 100644 --- a/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp +++ b/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp @@ -27,7 +27,6 @@ void cInterfaceEGL::DetectMode() return; EGLint num_configs; - EGLConfig *config = nullptr; bool supportsGL = false, supportsGLES2 = false, supportsGLES3 = false; std::array renderable_types = { EGL_OPENGL_BIT, @@ -51,16 +50,17 @@ void cInterfaceEGL::DetectMode() if (!eglChooseConfig( egl_dpy, attribs, nullptr, 0, &num_configs)) { INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n"); - goto err_exit; + continue; } - config = new EGLConfig[num_configs]; + EGLConfig* config = new EGLConfig[num_configs]; // Get all the configurations if (!eglChooseConfig(egl_dpy, attribs, config, num_configs, &num_configs)) { INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n"); - goto err_exit; + delete[] config; + continue; } for (int i = 0; i < num_configs; ++i) @@ -78,6 +78,7 @@ void cInterfaceEGL::DetectMode() supportsGLES2 = true; } } + delete[] config; } if (supportsGL) @@ -87,11 +88,8 @@ void cInterfaceEGL::DetectMode() else if (supportsGLES2) s_opengl_mode = GLInterfaceMode::MODE_OPENGLES2; -err_exit: if (s_opengl_mode == GLInterfaceMode::MODE_DETECT) // Errored before we found a mode s_opengl_mode = GLInterfaceMode::MODE_OPENGL; // Fall back to OpenGL - if (config) - delete[] config; } // Create rendering window.