From f87991504d55446fbe6298a4b8662ad059d575e0 Mon Sep 17 00:00:00 2001 From: espes Date: Tue, 14 Jul 2015 04:21:21 +1000 Subject: [PATCH] fix barbie horse adventures framebuffer corruption --- gl/gloffscreen_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gl/gloffscreen_common.c b/gl/gloffscreen_common.c index 408fcea2db..b9a53618b0 100644 --- a/gl/gloffscreen_common.c +++ b/gl/gloffscreen_common.c @@ -134,15 +134,15 @@ void glo_readpixels(GLenum gl_format, GLenum gl_type, /* Faster buffer flip */ GLubyte *b = (GLubyte *) data; GLubyte *c = &((GLubyte *) data)[stride * (height - 1)]; - GLubyte *tmp = (GLubyte *) g_malloc(stride); + GLubyte *tmp = (GLubyte *) g_malloc(width * bytes_per_pixel); int irow; glReadPixels(0, 0, width, height, gl_format, gl_type, data); for (irow = 0; irow < height / 2; irow++) { - memcpy(tmp, b, stride); - memcpy(b, c, stride); - memcpy(c, tmp, stride); + memcpy(tmp, b, width * bytes_per_pixel); + memcpy(b, c, width * bytes_per_pixel); + memcpy(c, tmp, width * bytes_per_pixel); b += stride; c -= stride; }