Skip to content

Commit

Permalink
Check if color exists in palette before using it
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Reschke <[email protected]>
  • Loading branch information
VicDeo authored and LukasReschke committed Feb 10, 2017
1 parent 3b70a57 commit a808233
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/private/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,12 +738,12 @@ private function imagecreatefrombmp($fileName) {
break;
case 8:
$color = @unpack('n', $vide . substr($data, $p, 1));
$color[1] = $palette[$color[1] + 1];
$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
break;
case 4:
$color = @unpack('n', $vide . substr($data, floor($p), 1));
$color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
$color[1] = $palette[$color[1] + 1];
$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
break;
case 1:
$color = @unpack('n', $vide . substr($data, floor($p), 1));
Expand Down Expand Up @@ -773,7 +773,7 @@ private function imagecreatefrombmp($fileName) {
$color[1] = ($color[1] & 0x1);
break;
}
$color[1] = $palette[$color[1] + 1];
$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
break;
default:
fclose($fh);
Expand Down

0 comments on commit a808233

Please sign in to comment.