From: José Fonseca Date: Fri, 10 May 2013 08:35:35 +0000 (+0100) Subject: glxtrace: Prevent overflow in glXBindTexImageEXT fo. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=d87aabdd0be10c2765c4b4e84508257b8e45a642;p=apitrace 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. --- 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()