Salome HOME
Protection for the case of python command wrapped over several lines
authoreap <eap@opencascade.com>
Fri, 31 Jul 2020 17:27:23 +0000 (20:27 +0300)
committereap <eap@opencascade.com>
Fri, 31 Jul 2020 17:27:23 +0000 (20:27 +0300)
src/SMESH_I/SMESH_2smeshpy.cxx

index 9ad3852900d66c165bb880333b877e68b24c077c..b36b31c13ea6f5d95e6836ef8329aeba6a9ed0f3 100644 (file)
@@ -3939,7 +3939,7 @@ int _pyCommand::GetArgBeginning() const
   if ( pos == UNKNOWN )
   {
     pos = GetBegPos( METHOD_IND ) + myMeth.Length();
-    if ( pos < 1 )
+    if ( pos < 1 && Length() >= 4 )
       pos = myString.Location( "(", 4, Length() ); // 4 = strlen("b.c(")
   }
   return pos;
@@ -4024,6 +4024,11 @@ TCollection_AsciiString _pyCommand::GetWord( const _AString & theString,
   }
   theStartPos = beg;
   //cout << theString << " ---- " << beg << " - " << end << endl;
+  if ( end > theString.Length() )
+  {
+    theStartPos = EMPTY;
+    return theEmptyString;
+  }
   return theString.SubString( beg, end );
 }