Commit 46974d29 by zmo@google.com

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
parent aa9c5ca9
...@@ -94,7 +94,7 @@ private: ...@@ -94,7 +94,7 @@ private:
bool SetFunctionCalled(TBuiltInFunction function); bool SetFunctionCalled(TBuiltInFunction function);
TVector<TBuiltInFunction> mFunctions; std::vector<TBuiltInFunction> mFunctions;
const bool* mFunctionMask; // a boolean flag for each function. const bool* mFunctionMask; // a boolean flag for each function.
const char** mFunctionSource; const char** mFunctionSource;
......
...@@ -23,7 +23,7 @@ TString mapLongName(int id, const TString& name, bool isVarying) ...@@ -23,7 +23,7 @@ TString mapLongName(int id, const TString& name, bool isVarying)
} // anonymous namespace } // anonymous namespace
MapLongVariableNames::MapLongVariableNames( MapLongVariableNames::MapLongVariableNames(
TMap<TString, TString>& varyingLongNameMap) std::map<std::string, std::string>& varyingLongNameMap)
: mVaryingLongNameMap(varyingLongNameMap) : mVaryingLongNameMap(varyingLongNameMap)
{ {
} }
...@@ -57,13 +57,13 @@ bool MapLongVariableNames::visitLoop(Visit, TIntermLoop* node) ...@@ -57,13 +57,13 @@ bool MapLongVariableNames::visitLoop(Visit, TIntermLoop* node)
TString MapLongVariableNames::mapVaryingLongName(const TString& name) 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()) if (it != mVaryingLongNameMap.end())
return (*it).second; return (*it).second.c_str();
int id = mVaryingLongNameMap.size(); int id = mVaryingLongNameMap.size();
TString mappedName = mapLongName(id, name, true); TString mappedName = mapLongName(id, name, true);
mVaryingLongNameMap.insert( 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; return mappedName;
} }
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
// longer than MAX_IDENTIFIER_NAME_SIZE to MAX_IDENTIFIER_NAME_SIZE. // longer than MAX_IDENTIFIER_NAME_SIZE to MAX_IDENTIFIER_NAME_SIZE.
class MapLongVariableNames : public TIntermTraverser { class MapLongVariableNames : public TIntermTraverser {
public: public:
MapLongVariableNames(TMap<TString, TString>& varyingLongNameMap); MapLongVariableNames(std::map<std::string, std::string>& varyingLongNameMap);
virtual void visitSymbol(TIntermSymbol*); virtual void visitSymbol(TIntermSymbol*);
virtual bool visitLoop(Visit, TIntermLoop*); virtual bool visitLoop(Visit, TIntermLoop*);
...@@ -27,7 +27,7 @@ public: ...@@ -27,7 +27,7 @@ public:
private: private:
TString mapVaryingLongName(const TString& name); TString mapVaryingLongName(const TString& name);
TMap<TString, TString>& mVaryingLongNameMap; std::map<std::string, std::string>& mVaryingLongNameMap;
}; };
#endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_ #endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_
...@@ -101,7 +101,7 @@ private: ...@@ -101,7 +101,7 @@ private:
TVariableInfoList uniforms; // Active uniforms in the compiled shader. TVariableInfoList uniforms; // Active uniforms in the compiled shader.
// Pair of long varying varibale name <originalName, mappedName>. // Pair of long varying varibale name <originalName, mappedName>.
TMap<TString, TString> varyingLongNameMap; std::map<std::string, std::string> varyingLongNameMap;
}; };
// //
......
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