mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0023403: Crash when parsing an expression with lexical error
Fix double freeing of memory in case when lexical error is detected by parser: - revert previous fix, instead nullify the global buffer after its freeing in ExprIntrp_stop_string(). Added new QA command CR23403 and test case
This commit is contained in:
parent
0c5acd2705
commit
9fe1ada847
@ -37,6 +37,7 @@ void ExprIntrp_start_string(char* str)
|
|||||||
void ExprIntrp_stop_string()
|
void ExprIntrp_stop_string()
|
||||||
{
|
{
|
||||||
ExprIntrp_delete_buffer(ExprIntrp_bufstring);
|
ExprIntrp_delete_buffer(ExprIntrp_bufstring);
|
||||||
|
ExprIntrp_bufstring = (YY_BUFFER_STATE) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int yywrap()
|
int yywrap()
|
||||||
|
24
src/QABugs/QABugs_11.cxx
Normal file → Executable file
24
src/QABugs/QABugs_11.cxx
Normal file → Executable file
@ -5330,6 +5330,29 @@ Standard_Integer bcarray (Draw_Interpretor& di, Standard_Integer argc, const cha
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <ExprIntrp_GenExp.hxx>
|
||||||
|
Standard_Integer CR23403 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
di << "Usage : " << argv[0] << " string\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_CString aString = argv[1];
|
||||||
|
Handle(ExprIntrp_GenExp) myExpr = ExprIntrp_GenExp::Create();
|
||||||
|
try {
|
||||||
|
OCC_CATCH_SIGNALS
|
||||||
|
myExpr->Process( aString );
|
||||||
|
}
|
||||||
|
catch(Standard_Failure) {
|
||||||
|
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||||
|
di << "Exception : " << aFail->GetMessageString() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void QABugs::Commands_11(Draw_Interpretor& theCommands) {
|
void QABugs::Commands_11(Draw_Interpretor& theCommands) {
|
||||||
const char *group = "QABugs";
|
const char *group = "QABugs";
|
||||||
|
|
||||||
@ -5439,5 +5462,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
|
|||||||
theCommands.Add("bcarray", "bcarray", __FILE__, bcarray, group);
|
theCommands.Add("bcarray", "bcarray", __FILE__, bcarray, group);
|
||||||
theCommands.Add("OCC22762", "OCC22762 x1 y1 z1 x2 y2 z3", __FILE__, OCC22762, group);
|
theCommands.Add("OCC22762", "OCC22762 x1 y1 z1 x2 y2 z3", __FILE__, OCC22762, group);
|
||||||
theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);
|
theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);
|
||||||
|
theCommands.Add("CR23403", "CR23403 string", __FILE__, CR23403, group);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,12 @@ puts ""
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
pload QAcommands
|
pload QAcommands
|
||||||
|
|
||||||
set R_check 0.45098000764846802
|
set r_1 0.4
|
||||||
set G_check 1
|
set r_2 0.5
|
||||||
set B_check 0.066666000000000003
|
set g_1 0.9
|
||||||
|
set g_2 1
|
||||||
|
set b_1 0
|
||||||
|
set b_2 0.1
|
||||||
set x1 128
|
set x1 128
|
||||||
set y1 235
|
set y1 235
|
||||||
box result 100 100 100
|
box result 100 100 100
|
||||||
@ -22,7 +25,28 @@ regexp {RED +: +([-0-9.+eE]+)} $color full rd
|
|||||||
regexp {GREEN +: +([-0-9.+eE]+)} $color full gr
|
regexp {GREEN +: +([-0-9.+eE]+)} $color full gr
|
||||||
regexp {BLUE +: +([-0-9.+eE]+)} $color full bl
|
regexp {BLUE +: +([-0-9.+eE]+)} $color full bl
|
||||||
|
|
||||||
if { $rd != $R_check || $gr != $G_check || $bl != $B_check} {
|
set red_status 0
|
||||||
|
if { $rd < $r_1 || $rd > $r_2 } {
|
||||||
|
set red_status 1
|
||||||
|
} else {
|
||||||
|
set red_status 0
|
||||||
|
}
|
||||||
|
|
||||||
|
set green_status 0
|
||||||
|
if { $gr < $g_1 || $gr > $g_2 } {
|
||||||
|
set green_status 1
|
||||||
|
} else {
|
||||||
|
set green_status 0
|
||||||
|
}
|
||||||
|
|
||||||
|
set blue_status 0
|
||||||
|
if { $bl < $b_1 || $bl > $b_2 } {
|
||||||
|
set blue_status 1
|
||||||
|
} else {
|
||||||
|
set blue_status 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if { $red_status != 0 || $green_status != 0 || $blue_status != 0 } {
|
||||||
puts "Error : color are not equal"
|
puts "Error : color are not equal"
|
||||||
puts "Error : QA command QAGetPixelColor doesn't work properly"
|
puts "Error : QA command QAGetPixelColor doesn't work properly"
|
||||||
}
|
}
|
||||||
|
12
tests/bugs/fclasses/CR23403
Executable file
12
tests/bugs/fclasses/CR23403
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#######################################################################
|
||||||
|
# Crash when parsing an expression with lexical error
|
||||||
|
#######################################################################
|
||||||
|
pload QAcommands
|
||||||
|
|
||||||
|
set result [CR23403 \t]
|
||||||
|
set length [llength ${result}]
|
||||||
|
|
||||||
|
puts ""
|
||||||
|
if { ${length} != 0 } {
|
||||||
|
puts "Error : parsing is incorrect"
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
001 demo
|
001 demo
|
||||||
002 iges
|
002 fclasses
|
||||||
003 xde
|
003 iges
|
||||||
|
004 xde
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user