Fix memory corruption in ANGLE shader translator.
The bug is that within each compilation cycle, all the memory allocated through T* types are freed to be reused. So if certain information is meant to outlive the cycle, it should use the std type instead of the T* type:
1) emulated function vector
2) mapped long names map
BUG=none
TEST=webgl conformance test conformance/glsl/glsl-feature-mod-gentype.html does not crash in Win Debug.
Review URL: http://codereview.appspot.com/5137047
git-svn-id: https://angleproject.googlecode.com/svn/trunk@773 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/MapLongVariableNames.cpp b/src/compiler/MapLongVariableNames.cpp
index 22dfab1..8f35560 100644
--- a/src/compiler/MapLongVariableNames.cpp
+++ b/src/compiler/MapLongVariableNames.cpp
@@ -23,7 +23,7 @@
} // anonymous namespace
MapLongVariableNames::MapLongVariableNames(
- TMap<TString, TString>& varyingLongNameMap)
+ std::map<std::string, std::string>& varyingLongNameMap)
: mVaryingLongNameMap(varyingLongNameMap)
{
}
@@ -57,13 +57,13 @@
TString MapLongVariableNames::mapVaryingLongName(const TString& name)
{
- TMap<TString, TString>::const_iterator it = mVaryingLongNameMap.find(name);
+ std::map<std::string, std::string>::const_iterator it = mVaryingLongNameMap.find(name.c_str());
if (it != mVaryingLongNameMap.end())
- return (*it).second;
+ return (*it).second.c_str();
int id = mVaryingLongNameMap.size();
TString mappedName = mapLongName(id, name, true);
mVaryingLongNameMap.insert(
- TMap<TString, TString>::value_type(name, mappedName));
+ std::map<std::string, std::string>::value_type(name.c_str(), mappedName.c_str()));
return mappedName;
}