From d87aabdd0be10c2765c4b4e84508257b8e45a642 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 10 May 2013 09:35:35 +0100 Subject: [PATCH] glxtrace: Prevent overflow in glXBindTexImageEXT fo. Stride needs to be 4bytes aligned. We should probably use GL_RGBA all the time, and avoid trouble here. --- wrappers/glxtrace.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py index 21bf8f1..0fb7d0b 100644 --- a/wrappers/glxtrace.py +++ b/wrappers/glxtrace.py @@ -137,7 +137,14 @@ class GlxTracer(GlTracer): GLenum type = GL_UNSIGNED_BYTE; if (target && internalformat && height && width && format) { GLint channels = _gl_format_channels(format); - GLvoid * pixels = malloc(height * width * channels); + // FIXME: This assumes (UN)PACK state is set to its + // defaults. We really should temporarily reset the state + // here (and emit according fake calls) to cope when its + // not. At very least we need a heads up warning that this + // will cause problems. + GLint alignment = 4; + GLint stride = _align(width * channels, alignment); + GLvoid * pixels = malloc(height * stride); _glGetTexImage(target, level, format, type, pixels); ''' self.emitFakeTexture2D() -- 2.43.0