diff --git a/src/Decoder.php b/src/Decoder.php index 2e90ecf..cceaf85 100644 --- a/src/Decoder.php +++ b/src/Decoder.php @@ -141,7 +141,7 @@ protected function decodeAnything(): ArrayObject|array|int|string protected function decodeDictionary(): ArrayObject { $values = []; - $lastKey = null; + $lastKey = ''; ++$this->offset; while ($this->offset <= $this->max) @@ -163,10 +163,11 @@ protected function decodeDictionary(): ArrayObject '5' => $this->decodeFastString('5:files', 7, 'files' ), default => $this->decodeString() }; - if (isset($lastKey) && strcmp($lastKey, $key) >= 0) + if (strcmp($lastKey, $key) >= 0 && !empty($values)) { $this->dictionaryComplianceError($key, $lastKey); } + if ($this->offset <= $this->max) { $values[$key] = $this->decodeAnything();