PHP: fix bug in serialization code

main
Christian Seiler 4 days ago
parent 8efc44d1c2
commit 2417aee259
  1. 2
      php/monoformat_structured.php

@ -26,7 +26,7 @@ function serializePixels(array $pixels): string {
function unserializePixels(int $n, string $serialized): array { function unserializePixels(int $n, string $serialized): array {
$nBytes = intdiv($n + 7, 8); $nBytes = intdiv($n + 7, 8);
if (strlen($serialized) != $nBytes) { if (strlen($serialized) != $nBytes) {
$actual = strlen($serializd); $actual = strlen($serialized);
throw new \ValueError("Could not unserialize a pixel bitmap: the size $actual does not equal the expected $nBytes"); throw new \ValueError("Could not unserialize a pixel bitmap: the size $actual does not equal the expected $nBytes");
} }
$result = array_fill(0, $n, false); $result = array_fill(0, $n, false);

Loading…
Cancel
Save