Browse Source

Fixed memory leak.

Björn Zeutzheim 12 years ago
parent
commit
c614a497ff
1 changed files with 3 additions and 1 deletions
  1. 3 1
      gameplay/src/Effect.cpp

+ 3 - 1
gameplay/src/Effect.cpp

@@ -483,7 +483,7 @@ Uniform* Effect::getUniform(const char* name) const
     if (uniformLocation > -1)
 	{
 		// Check for array uniforms ("u_directionalLightColor[0]" -> "u_directionalLightColor")
-		char* parentname = new char[strlen(name)];
+		char* parentname = new char[strlen(name)+1];
 		strcpy(parentname, name);
 		if (strtok(parentname, "[") != NULL) {
 			std::map<std::string, Uniform*>::const_iterator itr = _uniforms.find(parentname);
@@ -498,9 +498,11 @@ Uniform* Effect::getUniform(const char* name) const
 				uniform->_type = puniform->getType();
 				_uniforms[name] = uniform;
 
+				delete parentname;
 				return uniform;
 			}
 		}
+		delete parentname;
     }
 
 	// No uniform variable found - return NULL