]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check if color exists in palette before using it 3439/head
authorVictor Dubiniuk <victor.dubiniuk@gmail.com>
Tue, 31 Jan 2017 20:13:40 +0000 (23:13 +0300)
committerLukas Reschke <lukas@statuscode.ch>
Fri, 10 Feb 2017 15:27:51 +0000 (16:27 +0100)
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
lib/private/legacy/image.php

index 7f4295e3e93a22890f073e8035a233b0d559b3b5..47f2a977e9cc153e4b4b52fa464c890c92095f7a 100644 (file)
@@ -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);