]> git.cworth.org Git - apitrace/commitdiff
glxtrace: Prevent overflow in glXBindTexImageEXT fo.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 10 May 2013 08:35:35 +0000 (09:35 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 10 May 2013 08:35:35 +0000 (09:35 +0100)
Stride needs to be 4bytes aligned.  We should probably use
GL_RGBA all the time, and avoid trouble here.

wrappers/glxtrace.py

index 21bf8f144cea89f92f1588720a804da72aa1f748..0fb7d0b49d39876bec793e7f9c9555fe84ae7a34 100644 (file)
@@ -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()