changeset 11002:2538d03489cc

avoid infinite loop in regexp searches with PCRE
author John W. Eaton <jwe@octave.org>
date Mon, 20 Sep 2010 11:21:02 -0400
parents 2ab8cc6dcced
children b1cfff739af5
files src/ChangeLog src/DLD-FUNCTIONS/regexp.cc
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2010-09-20  John W. Eaton  <jwe@octave.org>
+
+	* DLD-FUNCTIONS/regexp.cc (octregexp_list) [HAVE_PCRE]:
+	Break from search loop if idx is at or beyond end of buffer
+	(bug #31056).
+
 2010-09-19  Ben Abbott <bpabbott@mac.com>
 
 	* graphics.h.in: Add displayname property to patch and surface objects.
--- a/src/DLD-FUNCTIONS/regexp.cc
+++ b/src/DLD-FUNCTIONS/regexp.cc
@@ -486,7 +486,7 @@
               idx = ovector[1];
               sz++;
 
-              if (once)
+              if (once || idx >= buffer.length ())
                 break;
 
             }