If a symbol is printed without a value list at the very end of a
basic_io dump, we might access a non-existing character position. This has been fixed and the string length calculation is now only done once.
This commit is contained in:
parent
eebdc5ad12
commit
0c575ccc74
@ -38,14 +38,15 @@ class IDF_Scm_Monotone_BasicIO
|
|||||||
{
|
{
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
$stanzas = array();
|
$stanzas = array();
|
||||||
|
$length = strlen($in);
|
||||||
|
|
||||||
while ($pos < strlen($in)) {
|
while ($pos < $length) {
|
||||||
$stanza = array();
|
$stanza = array();
|
||||||
while ($pos < strlen($in)) {
|
while ($pos < $length) {
|
||||||
if ($in[$pos] == "\n") break;
|
if ($in[$pos] == "\n") break;
|
||||||
|
|
||||||
$stanzaLine = array('key' => '', 'values' => array(), 'hash' => null);
|
$stanzaLine = array('key' => '', 'values' => array(), 'hash' => null);
|
||||||
while ($pos < strlen($in)) {
|
while ($pos < $length) {
|
||||||
$ch = $in[$pos];
|
$ch = $in[$pos];
|
||||||
if ($ch == '"' || $ch == '[') break;
|
if ($ch == '"' || $ch == '[') break;
|
||||||
++$pos;
|
++$pos;
|
||||||
@ -53,6 +54,9 @@ class IDF_Scm_Monotone_BasicIO
|
|||||||
$stanzaLine['key'] .= $ch;
|
$stanzaLine['key'] .= $ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// symbol w/o a value list
|
||||||
|
if ($pos >= $length || $in[$pos] == "\n") break;
|
||||||
|
|
||||||
if ($in[$pos] == '[') {
|
if ($in[$pos] == '[') {
|
||||||
unset($stanzaLine['values']);
|
unset($stanzaLine['values']);
|
||||||
++$pos; // opening square bracket
|
++$pos; // opening square bracket
|
||||||
@ -67,7 +71,7 @@ class IDF_Scm_Monotone_BasicIO
|
|||||||
while ($in[$pos] == '"') {
|
while ($in[$pos] == '"') {
|
||||||
++$pos; // opening quote
|
++$pos; // opening quote
|
||||||
$stanzaLine['values'][$valCount] = '';
|
$stanzaLine['values'][$valCount] = '';
|
||||||
while ($pos < strlen($in)) {
|
while ($pos < $length) {
|
||||||
$ch = $in[$pos]; $pr = $in[$pos-1];
|
$ch = $in[$pos]; $pr = $in[$pos-1];
|
||||||
if ($ch == '"' && $pr != '\\') break;
|
if ($ch == '"' && $pr != '\\') break;
|
||||||
++$pos;
|
++$pos;
|
||||||
@ -75,7 +79,7 @@ class IDF_Scm_Monotone_BasicIO
|
|||||||
}
|
}
|
||||||
++$pos; // closing quote
|
++$pos; // closing quote
|
||||||
|
|
||||||
if ($pos >= strlen($in))
|
if ($pos >= $length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ($in[$pos] == ' ') {
|
if ($in[$pos] == ' ') {
|
||||||
|
Loading…
Reference in New Issue
Block a user