1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-13 14:27:08 +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:
vsr
2012-09-07 14:19:09 +04:00
parent 0c5acd2705
commit 9fe1ada847
5 changed files with 69 additions and 6 deletions

View File

@@ -37,6 +37,7 @@ void ExprIntrp_start_string(char* str)
void ExprIntrp_stop_string()
{
ExprIntrp_delete_buffer(ExprIntrp_bufstring);
ExprIntrp_bufstring = (YY_BUFFER_STATE) 0;
}
int yywrap()

24
src/QABugs/QABugs_11.cxx Normal file → Executable file
View File

@@ -5330,6 +5330,29 @@ Standard_Integer bcarray (Draw_Interpretor& di, Standard_Integer argc, const cha
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) {
const char *group = "QABugs";
@@ -5439,5 +5462,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
theCommands.Add("bcarray", "bcarray", __FILE__, bcarray, 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("CR23403", "CR23403 string", __FILE__, CR23403, group);
return;
}