Selaa lähdekoodia

BUG: if there is no match, don't construct the stl string from a NULL
pointer

Alex

Alexander Neundorf 18 vuotta sitten
vanhempi
sitoutus
a43976e91d
1 muutettua tiedostoa jossa 8 lisäystä ja 1 poistoa
  1. 8 1
      Source/kwsys/RegularExpression.hxx.in

+ 8 - 1
Source/kwsys/RegularExpression.hxx.in

@@ -379,7 +379,14 @@ inline kwsys_stl::string::size_type RegularExpression::end(int n) const
  */
 inline kwsys_stl::string RegularExpression::match(int n) const
 {
-  return kwsys_stl::string(this->startp[n], this->endp[n] - this->startp[n]);
+  if (this->startp[n]==0)
+    {
+    return kwsys_stl::string("");
+    }
+  else
+    {
+    return kwsys_stl::string(this->startp[n], this->endp[n] - this->startp[n]);
+    }
 }
 
 } // namespace @KWSYS_NAMESPACE@