From 6342762fdeb349b9c0592bb9f6becf868243ad6a Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 1 Dec 2016 02:39:52 -0800 Subject: [PATCH 1/2] FIx a potential bug when using _glUniform calls with an invalid location --- libraries/gpu-gl/src/gpu/gl/GLShader.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLShader.h b/libraries/gpu-gl/src/gpu/gl/GLShader.h index 40dd0b7be9..07a17f458d 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLShader.h +++ b/libraries/gpu-gl/src/gpu/gl/GLShader.h @@ -40,10 +40,14 @@ public: return _shaderObjects[version].glprogram; } - GLint getUniformLocation(GLint srcLoc, Version version = Mono) { + GLint getUniformLocation(GLint srcLoc, Version version = Mono) const { // THIS will be used in the future PR as we grow the number of versions - return _uniformMappings[version][srcLoc]; - // return srcLoc; + const auto& mapping = _uniformMappings[version]; + auto found = mapping.find(srcLoc); + if (found == mapping.end()) { + return -1; + } + return found->second; } const std::weak_ptr _backend; From 3d291871565ca77e0ed0e1df4d3c08dc22a3da72 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 1 Dec 2016 02:44:04 -0800 Subject: [PATCH 2/2] FIx a potential bug when using _glUniform calls with an invalid location --- libraries/gpu-gl/src/gpu/gl/GLShader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLShader.h b/libraries/gpu-gl/src/gpu/gl/GLShader.h index 07a17f458d..e03b487a60 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLShader.h +++ b/libraries/gpu-gl/src/gpu/gl/GLShader.h @@ -41,7 +41,7 @@ public: } GLint getUniformLocation(GLint srcLoc, Version version = Mono) const { - // THIS will be used in the future PR as we grow the number of versions + // This check protect against potential invalid src location for this shader, if unknown then return -1. const auto& mapping = _uniformMappings[version]; auto found = mapping.find(srcLoc); if (found == mapping.end()) {