aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-15 13:41:28 +0100
committerAlon Zakai <alonzakai@gmail.com>2013-02-15 13:41:28 +0100
commitfe1a6bbac46a4b1caabfb2e71d7680305f256894 (patch)
tree58f2a8064c4b3f32d4f22246eb15ac18bc6b09f6 /tests
parentf8fbf5a424e630e194a8068a799c22d10229ea15 (diff)
memory checks for glReadPixels
Diffstat (limited to 'tests')
-rw-r--r--tests/sdl_gl_read.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/sdl_gl_read.c b/tests/sdl_gl_read.c
index 552eb8c0..d752f94d 100644
--- a/tests/sdl_gl_read.c
+++ b/tests/sdl_gl_read.c
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <assert.h>
GLuint programObject;
int width = 512;
@@ -118,8 +119,14 @@ void Draw ()
}
void Verify() {
- unsigned char *data = malloc(width*height*4);
+ unsigned char *data = malloc(width*height*4 + 16);
+ int *last = (int*)(data + width*height*4 - 4);
+ int *after = (int*)(data + width*height*4);
+ *last = 0xdeadbeef;
+ *after = 0x12345678;
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ assert(*last != 0xdeadbeef); // should overwrite the buffer to the end
+ assert(*after == 0x12345678); // nothing should be written afterwards!
// Should see some blue, and nothing else
int seen = 0;
int ok = 1;