Ensure that strings produced by getVariableInfo are always null-terminated

Issue 326 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1070 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 30a487c7
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1067 #define BUILD_REVISION 1070
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -72,12 +72,14 @@ static void getVariableInfo(ShShaderInfo varType, ...@@ -72,12 +72,14 @@ static void getVariableInfo(ShShaderInfo varType,
int activeUniformAndAttribLength = 1 + MAX_SYMBOL_NAME_LEN; int activeUniformAndAttribLength = 1 + MAX_SYMBOL_NAME_LEN;
ASSERT(checkActiveUniformAndAttribMaxLengths(handle, activeUniformAndAttribLength)); ASSERT(checkActiveUniformAndAttribMaxLengths(handle, activeUniformAndAttribLength));
strncpy(name, varInfo.name.c_str(), activeUniformAndAttribLength); strncpy(name, varInfo.name.c_str(), activeUniformAndAttribLength);
name[activeUniformAndAttribLength - 1] = 0;
if (mappedName) { if (mappedName) {
// This size must match that queried by // This size must match that queried by
// SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below. // SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below.
int maxMappedNameLength = 1 + MAX_SYMBOL_NAME_LEN; int maxMappedNameLength = 1 + MAX_SYMBOL_NAME_LEN;
ASSERT(checkMappedNameMaxLength(handle, maxMappedNameLength)); ASSERT(checkMappedNameMaxLength(handle, maxMappedNameLength));
strncpy(mappedName, varInfo.mappedName.c_str(), maxMappedNameLength); strncpy(mappedName, varInfo.mappedName.c_str(), maxMappedNameLength);
mappedName[maxMappedNameLength - 1] = 0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment