aboutsummaryrefslogtreecommitdiff
path: root/src/library_gl.js
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-11-19 11:37:09 +0200
committerJukka Jylänki <jujjyl@gmail.com>2013-12-13 18:07:04 +0200
commit82e6c95c89fb2a4f6668dda3ea40160999a11253 (patch)
treec498e9e4bc52e1576d6b709a62f658bf41c9a6c2 /src/library_gl.js
parent3e061d95104b88d6209d892bbda24e18a1539073 (diff)
Generate an GL_INVALID_VALUE error when user calls glGetXXX() with a null out pointer instead of crashing. Fix glGetIntegerv of GL_SHADER_BINARY_FORMATS to not write anything out to the provided buffer.
Diffstat (limited to 'src/library_gl.js')
-rw-r--r--src/library_gl.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index cc39b048..6fb2643d 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -210,6 +210,17 @@ var LibraryGL = {
},
get: function(name_, p, type) {
+ // Guard against user passing a null pointer.
+ // Note that GLES2 spec does not say anything about how passing a null pointer should be treated.
+ // Testing on desktop core GL 3, the application crashes on glGetIntegerv to a null pointer, but
+ // better to report an error instead of doing anything random.
+ if (!p) {
+#if GL_ASSERTIONS
+ Module.printErr('GL_INVALID_VALUE in glGet' + type + 'v(name=' + name_ + ': Function called with null out pointer!');
+#endif
+ GL.recordError(0x0501 /* GL_INVALID_VALUE */);
+ return;
+ }
var ret = undefined;
switch(name_) { // Handle a few trivial GLES values
case 0x8DFA: // GL_SHADER_COMPILER