changeset 23769:fdce2b73f5ce stable

regexp.cc: Correctly size temporary buffer to avoid segfault when re-arranging outputs. * regexp.cc (octregexp): Change OCTAVE_LOCAL_BUFFER to OCTAVE_LOCAL_BUFFER_INIT. Change size of temporary buffer to 7 (number of return args for function) rather than 6. Initialize temporary to false. Change for loop bound to 7 to operate over all possible outputs.
author Rik <rik@octave.org>
date Wed, 19 Jul 2017 11:41:25 -0700
parents efba56b2406f
children fdc60d7b777e d396866fa7d8
files libinterp/corefcn/regexp.cc
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/regexp.cc	Thu Jul 13 15:57:05 2017 -0700
+++ b/libinterp/corefcn/regexp.cc	Wed Jul 19 11:41:25 2017 -0700
@@ -468,9 +468,7 @@
       octave_value_list new_retval;
       new_retval.resize (nargout);
 
-      OCTAVE_LOCAL_BUFFER (int, arg_used, 6);
-      for (int j = 0; j < 6; j++)
-        arg_used[j] = false;
+      OCTAVE_LOCAL_BUFFER_INIT (int, arg_used, 7, false);
 
       for (int j = 2; j < nargin; j++)
         {
@@ -515,7 +513,7 @@
       // Fill in the rest of the arguments
       if (n < nargout)
         {
-          for (int j = 0; j < 6; j++)
+          for (int j = 0; j < 7; j++)
             {
               if (! arg_used[j])
                 new_retval(n++) = retval(j);