[Fixed] Crash in D3D11HLSLProgram::compileMicrocode()

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Odessa, Ukraine
x 41

[Fixed] Crash in D3D11HLSLProgram::compileMicrocode()

Post by Eugene »

The reason is pDefines is initialized with address of variable that is destructed before pDefines is used. Simple fix is attached, but it`s really bad design, that would bites again and again.

Code: Select all

@@ -359,11 +359,11 @@
         HLSLIncludeHandler includeHandler(this);
 
         ID3DBlob * errors = 0;
+        String stringBuffer;
+        vector<D3D_SHADER_MACRO>::type defines;
         const D3D_SHADER_MACRO* pDefines = NULL;
         if (!shaderMacroSet)
         {
-            String stringBuffer;
-            vector<D3D_SHADER_MACRO>::type defines;
             getDefines(stringBuffer, defines, mPreprocessorDefines);
             pDefines = defines.empty() ? NULL : &defines[0];
         }
Last edited by Eugene on Thu Nov 01, 2012 10:54 pm, edited 2 times in total.

User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Odessa, Ukraine
x 41

Re: Crash in D3D11HLSLProgram::compileMicrocode()

Post by Eugene »

OK, my patch was accepted, issue closed

Post Reply