[casacore] r21573 committed - Fixed re-entrancy problem in nested ImageExpr parsing

0 views
Skip to first unread message

casa...@googlecode.com

unread,
Mar 10, 2015, 6:47:31 AM3/10/15
to casacor...@googlegroups.com
Revision: 21573
Author: gervandiepen
Date: Tue Mar 10 10:47:14 2015 UTC
Log: Fixed re-entrancy problem in nested ImageExpr parsing
https://code.google.com/p/casacore/source/detail?r=21573

Modified:
/trunk/images/Images/ImageExprGram.cc
/trunk/images/Images/ImageExprParse.cc

=======================================
--- /trunk/images/Images/ImageExprGram.cc Wed Aug 27 07:59:38 2014 UTC
+++ /trunk/images/Images/ImageExprGram.cc Tue Mar 10 10:47:14 2015 UTC
@@ -67,9 +67,16 @@
{
ImageExprGramrestart (ImageExprGramin);
yy_start = 1;
+ // Save global state for re-entrancy.
+ const char* savStrpImageExprGram = strpImageExprGram;
+ Int savPosImageExprGram= posImageExprGram;
strpImageExprGram = command.chars(); // get pointer to command
string
posImageExprGram = 0; // initialize string position
- return ImageExprGramparse(); // parse command string
+ int sts = ImageExprGramparse(); // parse command string
+ // Restore global state.
+ strpImageExprGram = savStrpImageExprGram;
+ posImageExprGram= savPosImageExprGram;
+ return sts;
}

//# Give the string position.
=======================================
--- /trunk/images/Images/ImageExprParse.cc Mon Jul 5 11:44:27 2010 UTC
+++ /trunk/images/Images/ImageExprParse.cc Tue Mar 10 10:47:14 2015 UTC
@@ -68,6 +68,27 @@
//# Hold a pointer to the last HDF5 file to lookup unqualified region
names.
static CountedPtr<HDF5File> theLastHDF5;

+#define SAVE_GLOBALS \
+ const Block<LatticeExprNode>* savTempLattices=theTempLattices; \
+ const PtrBlock<const ImageRegion*>* savTempRegions=theTempRegions; \
+ String savDirName=theDirName; \
+ Block<void*> savNodes=theNodes; \
+ Block<Bool> savNodesType=theNodesType; \
+ uInt savNrNodes=theNrNodes; \
+ Table savLastTable=theLastTable; \
+ CountedPtr<HDF5File> savLastHDF5=theLastHDF5;
+
+#define RESTORE_GLOBALS \
+ theTempLattices=savTempLattices; \
+ theTempRegions=savTempRegions; \
+ theDirName=savDirName; \
+ theNodes=savNodes; \
+ theNodesType=savNodesType; \
+ theNrNodes=savNrNodes; \
+ theLastTable=savLastTable; \
+ theLastHDF5=savLastHDF5;
+
+
// Clear the global info.
void imageExprParse_clear()
{
@@ -181,6 +202,8 @@
const PtrBlock<const ImageRegion*>& tempRegions,
const String& dirName)
{
+ // Save the global variables to make it re-entrant.
+ SAVE_GLOBALS;
theTempLattices = &tempLattices;
theTempRegions = &tempRegions;
theDirName = dirName;
@@ -209,6 +232,8 @@
throw (AipsError(message + '\n' + "Scanned so far: " +
command.before(imageExprGramPosition())));
}
+ // Restore the global variables to make it re-entrant.
+ RESTORE_GLOBALS;
return node;
}

Reply all
Reply to author
Forward
0 new messages