changeset 21463:a4c411681e25

avoid out of bounds indexed assignment in textscan * textscan.cc (textscan::parse_options): Avoid possible out of bounds assignment to delim_table.
author John W. Eaton <jwe@octave.org>
date Thu, 17 Mar 2016 16:09:21 -0400
parents b7d1e93c0702
children 6e5540ddb639
files libinterp/corefcn/textscan.cc
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/textscan.cc	Tue Mar 15 19:36:52 2016 +1100
+++ b/libinterp/corefcn/textscan.cc	Thu Mar 17 16:09:21 2016 -0400
@@ -1385,8 +1385,10 @@
 
   // Create look-up table of delimiters, based on 'delimiter'
   delim_table = std::string (256, '\0');
-  delim_table[eol1] = '1';        // EOL is always a delimiter
-  delim_table[eol2] = '1';        // EOL is always a delimiter
+  if (eol1 >= 0 && eol1 < 256)
+    delim_table[eol1] = '1';        // EOL is always a delimiter
+  if (eol2 >= 0 && eol2 < 256)
+    delim_table[eol2] = '1';        // EOL is always a delimiter
   if (!have_delims)
     for (unsigned int i = 0; i < 256; i++)
       {