aboutsummaryrefslogtreecommitdiff
path: root/parser.php
diff options
context:
space:
mode:
authorJean-Michel Vedrine <vedrine@vedrine.org>2017-12-29 16:30:18 +0100
committerJean-Michel Vedrine <vedrine@vedrine.org>2017-12-29 16:30:18 +0100
commit525f241be6e567220ec806371ad27a01e98c303e (patch)
tree776f02258569961a2d70dd50f14da66b3fc8aa06 /parser.php
parent3fe95d7824d74298e28c9449f79cdaca6ead6bb4 (diff)
Solve uninitialized string index when no subscript
Diffstat (limited to 'parser.php')
-rw-r--r--parser.php4
1 files 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]);