changeset 12786:4e70c4e61c24 stable

strfind.cc: Fix infinite loop when pattern contains 255 (Bug #33670). strfind.cc: Increase match table size by 1 to account for possible UCHAR_MAX of 255.
author Rik <octave@nomad.inbox5.com>
date Thu, 14 Jul 2011 11:40:24 -0700
parents 944cf42c699e
children 5fab4848ea1e 4c93cc41da15
files src/DLD-FUNCTIONS/strfind.cc
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/strfind.cc	Wed Jun 29 21:07:46 2011 -0700
+++ b/src/DLD-FUNCTIONS/strfind.cc	Thu Jul 14 11:40:24 2011 -0700
@@ -50,7 +50,7 @@
   const char *x = needle.data ();
   octave_idx_type m = needle.numel ();
 
-   for (octave_idx_type i = 0; i < UCHAR_MAX; i++)
+   for (octave_idx_type i = 0; i < TABSIZE; i++)
       table[i] = m + 1;
    for (octave_idx_type i = 0; i < m; i++)
       table[ORD(x[i])] = m - i;
@@ -203,7 +203,7 @@
       if (argpat.is_string ())
         {
           Array<char> needle = argpat.char_array_value ();
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, UCHAR_MAX);
+          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
           qs_preprocess (needle, table);
 
           if (argstr.is_string ())
@@ -367,7 +367,7 @@
           const Array<char> pat = argpat.char_array_value ();
           const Array<char> rep = argrep.char_array_value ();
 
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, UCHAR_MAX);
+          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
           qs_preprocess (pat, table);
 
           if (argstr.is_string ())