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/BuiltInFunctionEmulator.h b/src/compiler/BuiltInFunctionEmulator.h
index 28114fc..b37b665 100644
--- a/src/compiler/BuiltInFunctionEmulator.h
+++ b/src/compiler/BuiltInFunctionEmulator.h
@@ -94,7 +94,7 @@
bool SetFunctionCalled(TBuiltInFunction function);
- TVector<TBuiltInFunction> mFunctions;
+ std::vector<TBuiltInFunction> mFunctions;
const bool* mFunctionMask; // a boolean flag for each function.
const char** mFunctionSource;
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;
}
diff --git a/src/compiler/MapLongVariableNames.h b/src/compiler/MapLongVariableNames.h
index b8ab449..46f19b8 100644
--- a/src/compiler/MapLongVariableNames.h
+++ b/src/compiler/MapLongVariableNames.h
@@ -19,7 +19,7 @@
// longer than MAX_IDENTIFIER_NAME_SIZE to MAX_IDENTIFIER_NAME_SIZE.
class MapLongVariableNames : public TIntermTraverser {
public:
- MapLongVariableNames(TMap<TString, TString>& varyingLongNameMap);
+ MapLongVariableNames(std::map<std::string, std::string>& varyingLongNameMap);
virtual void visitSymbol(TIntermSymbol*);
virtual bool visitLoop(Visit, TIntermLoop*);
@@ -27,7 +27,7 @@
private:
TString mapVaryingLongName(const TString& name);
- TMap<TString, TString>& mVaryingLongNameMap;
+ std::map<std::string, std::string>& mVaryingLongNameMap;
};
#endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_
diff --git a/src/compiler/ShHandle.h b/src/compiler/ShHandle.h
index 759d50a..8ddf0f1 100644
--- a/src/compiler/ShHandle.h
+++ b/src/compiler/ShHandle.h
@@ -101,7 +101,7 @@
TVariableInfoList uniforms; // Active uniforms in the compiled shader.
// Pair of long varying varibale name <originalName, mappedName>.
- TMap<TString, TString> varyingLongNameMap;
+ std::map<std::string, std::string> varyingLongNameMap;
};
//