From 29e3c79e8b538d2915f341f35228a542d3b7bfc2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 16 Mar 2015 16:22:48 +0100 Subject: [PATCH] (GL) Deal with some potential memory leaks --- gfx/drivers/gl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index a8d481e33c..db408bfce3 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2780,10 +2780,23 @@ unsigned *height_p, size_t *pitch_p) #ifdef HAVE_FBO if (gl->hw_render_use) + { buffer = malloc(pitch * height); + if (!buffer) + return NULL; + } #endif buffer_texture = malloc(pitch * gl->tex_h); + if (!buffer_texture) + { +#ifdef HAVE_FBO + if (buffer) + free(buffer); +#endif + return NULL; + } + glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); glGetTexImage(GL_TEXTURE_2D, 0,gl->texture_type, gl->texture_fmt, buffer_texture);