From 525f241be6e567220ec806371ad27a01e98c303e Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Fri, 29 Dec 2017 16:30:18 +0100 Subject: Solve uninitialized string index when no subscript --- parser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parser.php b/parser.php index 075b662..05440a7 100644 --- a/parser.php +++ b/parser.php @@ -670,7 +670,7 @@ class qtype_algebra_parser_variable extends qtype_algebra_parser_term { // Now set the subscript to the remaining letters. $this->_subscript = substr($text, 1); // If the first letter of the subscript is an underscore then remove it. - if ($this->_subscript[0] == '_') { + if (strlen($this->_subscript) != 0 && $this->_subscript[0] == '_') { $this->_subscript = substr($this->_subscript, 1); } // Call the base class constructor with the variable text set to the combination of the @@ -1596,7 +1596,7 @@ class qtype_algebra_parser { $token[1] == 'qtype_algebra_parser_function' or $token[1] == 'qtype_algebra_parser_special') and (is_array($tree[count($tree) - 1]) or - $tree[count($tree)-1]->n_args() == 0)) { + $tree[count($tree) - 1]->n_args() == 0)) { array_push($tree, new qtype_algebra_parser_multiply('*')); } $i += strlen($m[0]); -- cgit v1.2.3