# HG changeset patch # User Rik # Date 1310668824 25200 # Node ID 4e70c4e61c24bf978b0f4853f9f5e2ff1e510b51 # Parent 944cf42c699e32978009df6ab1baea9284795b8c 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. diff --git a/src/DLD-FUNCTIONS/strfind.cc b/src/DLD-FUNCTIONS/strfind.cc --- a/src/DLD-FUNCTIONS/strfind.cc +++ b/src/DLD-FUNCTIONS/strfind.cc @@ -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 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 pat = argpat.char_array_value (); const Array 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 ())