0029651: ViewerTest - vtexture command crashes IR-2018-04-10
authorsan <san@opencascade.com>
Tue, 27 Mar 2018 08:54:12 +0000 (11:54 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 10 Apr 2018 13:07:11 +0000 (16:07 +0300)
Missing null check added

Add test case bugs/vis/bug29651

src/ViewerTest/ViewerTest.cxx
tests/bugs/vis/bug29651 [new file with mode: 0644]

index a81276b..e81f4cf 100644 (file)
@@ -3863,7 +3863,11 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       {
         aTextureVecNew.SetValue (aTexIndex, Handle(Graphic3d_Texture2Dmanual)());
       }
-      aTextureVecNew.ChangeValue (aTexIndex)->GetParams()->SetTextureUnit ((Graphic3d_TextureUnit )aTexIndex);
+
+      if (aTextureVecNew.Value (aTexIndex))
+      {
+        aTextureVecNew.ChangeValue(aTexIndex)->GetParams()->SetTextureUnit((Graphic3d_TextureUnit)aTexIndex);
+      }
     }
     else
     {
diff --git a/tests/bugs/vis/bug29651 b/tests/bugs/vis/bug29651
new file mode 100644 (file)
index 0000000..b0fd702
--- /dev/null
@@ -0,0 +1,17 @@
+puts "========"
+puts "OCC29651"
+puts "========"
+puts ""
+##########################################
+# ViewerTest - vtexture command crashes
+##########################################
+
+vinit
+vsetdispmode 1
+box b 1 2 3
+vdisplay b
+vfit
+vtexture b 0
+vtexture b off
+
+checkview -screenshot -3d -path ${imagedir}/${test_image}.png