Skip to content

Commit 85cb7e3

Browse files
committed
Fixes an "Undefined offset: 1" PHP Notice.
When using DejaVu Sans or any @font-face font, this would always throw PHP errors in my app. It makes sense to check if it's set to prevent the notice. Ideally, though, this shouldn't even be throwing errors, but I don't know enough about php-font-lib's code to figure out what is going on. Here's a minimal test case HTML that causes the error: http://i.28hours.org/files/php-font-lib-undefined-offset.html
1 parent f4e096e commit 85cb7e3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/FontLib/BinaryStream.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ public function w($type, $data) {
411411

412412
$ret = 0;
413413
for ($i = 0; $i < $type[1]; $i++) {
414-
$ret += $this->w($type[0], $data[$i]);
414+
if (isset($data[$i])) {
415+
$ret += $this->w($type[0], $data[$i]);
416+
}
415417
}
416418

417419
return $ret;

0 commit comments

Comments
 (0)