0023500: MFC samples are crached on 3D visualisation
authoribs <ibs@opencascade.com>
Fri, 9 Nov 2012 08:11:20 +0000 (12:11 +0400)
committeribs <ibs@opencascade.com>
Fri, 9 Nov 2012 11:28:40 +0000 (15:28 +0400)
void FreeTexture() in OpenGl_TextureBox.cxx - avoid possible NULL-pointer dereference

after debug x64 compilation the executable viewer3d had been moved to the bin folder. now executable viewer3d located in bind folder.

samples/mfc/standard/04_Viewer3d/adm/win/vc10/Viewer3d.vcxproj
src/OpenGl/OpenGl_TextureBox.cxx

index 3e84d69..63f3bb2 100644 (file)
     </ResourceCompile>
     <Link>
       <AdditionalDependencies>TKBRep.lib;FWOSPlugin.lib;PTKernel.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPCAF.lib;TKPrim.lib;TKPShape.lib;TKService.lib;TKTopAlgo.lib;TKV2d.lib;TKV3d.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <OutputFile>../../../../x64\vc10\bin/Viewer3d.exe</OutputFile>
+      <OutputFile>../../../../x64\vc10\bind/Viewer3d.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>..\..\..\..\x64\vc10\libd;$(CSF_OPT_LIB64D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <GenerateDebugInformation>true</GenerateDebugInformation>
index 3342ff2..5f9f139 100755 (executable)
@@ -684,7 +684,10 @@ void FreeTexture (const Handle(OpenGl_Context)& theContext,
     for (int i = 0; i < textab(ID).contextdata.Length(); ++i)
     {
       Handle(OpenGl_ResourceTexture) aResource = new OpenGl_ResourceTexture (textab(ID).contextdata(i).number);
-      theContext->DelayedRelease (aResource);
+      
+      if (!theContext.IsNull()) {
+        theContext->DelayedRelease (aResource);
+      }
     }
 
     texdata(data).status = TEXDATA_NONE;