From: Victor Dubiniuk Date: Tue, 31 Jan 2017 20:13:40 +0000 (+0300) Subject: Check if color exists in palette before using it X-Git-Tag: v12.0.0beta1~544^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2585f195da76b278e0a8539c23e6b0d32000656e;p=nextcloud-server.git Check if color exists in palette before using it Signed-off-by: Lukas Reschke --- diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php index 7f4295e3e93..47f2a977e9c 100644 --- a/lib/private/legacy/image.php +++ b/lib/private/legacy/image.php @@ -760,12 +760,12 @@ class OC_Image implements \OCP\IImage { 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)); @@ -795,7 +795,7 @@ class OC_Image implements \OCP\IImage { $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);