From 2585f195da76b278e0a8539c23e6b0d32000656e Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Tue, 31 Jan 2017 23:13:40 +0300 Subject: [PATCH] Check if color exists in palette before using it Signed-off-by: Lukas Reschke --- lib/private/legacy/image.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); -- 2.39.5