1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00
occt/tests/bugs/step/bug33487
dkulikov 539ddf30fb 0033487: Data Exchange, Step Import - Unresolved reference crashes
Fixed crash in STEPConstruct_Styles::GetColors() due to nullptr
  dereferencing when source step file has missing
  FILL_AREA_STYLE_COLOUR entities.
2024-09-25 08:16:26 +00:00

38 lines
1.6 KiB
Plaintext

puts "# ====================================================================="
puts "# 0033487: Data Exchange, Step Import - Unresolved reference crashes"
puts "# ====================================================================="
# This test checks if crash happens when reading step file with missing
# FILL_AREA_STYLE_COLOUR entities.
# Read original file as plain text.
set aSourceFilePath [locate_data_file trj6_as1-hc-214.stp]
set aSourceFileChannel [open $aSourceFilePath r]
set aSourceTextData [read $aSourceFileChannel]
close $aSourceFileChannel
# Create a 'broken' text data for step file by removing all FILL_AREA_STYLE_COLOUR entities.
set aBrokenStepTextData ""
set aToRemove "FILL_AREA_STYLE_COLOUR"
set aSourceFileLines [split $aSourceTextData ";"]
foreach aCurrentLine $aSourceFileLines {
if {[string first $aToRemove $aCurrentLine] == -1} {
# Add all strings from source file, except for strings that contain FILL_AREA_STYLE_COLOUR,
# to the new file.
append aBrokenStepTextData $aCurrentLine ";"
}
}
# Write 'broken' plain text data into temporary step file.
set aTmpFilePath "$imagedir/${casename}.stp"
set aTmpFileChannel [open $aTmpFilePath w]
puts $aTmpFileChannel $aBrokenStepTextData
close $aTmpFileChannel
# Read temporary file and delete it.
# If something is wrong with step reader, crash will occur while executing ReadFile command.
# If step reader works correctly, we expect just 'Unresolved Reference' message.
puts {REQUIRED All: ERR StepReaderData : Unresolved Reference : Fails Count : 39}
ReadFile aDoc $aTmpFilePath
file delete $aTmpFilePath