MemoryManager: scrub string keys for dumping

fixes crashes such as https://crash.pmmp.io/view/5986490
this also ensures that the order of elements is maintained when decoded by another software.
This commit is contained in:
Dylan K. Taylor 2022-02-20 20:54:03 +00:00
parent d60dba2de0
commit bd4c2b5245
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -508,8 +508,13 @@ class MemoryManager{
return "(error) ARRAY RECURSION LIMIT REACHED";
}
$data = [];
$numeric = 0;
foreach($from as $key => $value){
$data[$key] = self::continueDump($value, $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize);
$data[$numeric] = [
"k" => self::continueDump($key, $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize),
"v" => self::continueDump($value, $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize),
];
$numeric++;
}
}elseif(is_string($from)){
$data = "(string) len(" . strlen($from) . ") " . substr(Utils::printable($from), 0, $maxStringSize);