File 0001-Bug-701176-Handle-TIFFs-with-alpha-that-have-more-th.patch of Package mupdf.17658

From cdd916c66d1f66caa57b2bb738bfc4a202d388e4 Mon Sep 17 00:00:00 2001
From: Sebastian Rasmussen <sebras@gmail.com>
Date: Mon, 10 Jun 2019 13:58:28 +0200
Subject: [PATCH 1/2] Bug 701176: Handle TIFFs with alpha that have more than 8
 bits per sample.

(cherry picked from commit b7892cdc7fae62aa57d63ae62144e1f11b5f9275)
---
 source/fitz/load-tiff.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index 80abd6f1f..993f24bba 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -268,7 +268,10 @@ tiff_expand_colormap(fz_context *ctx, struct tiff *tiff)
 				*dst++ = tiff->colormap[c + 0] >> 8;
 				*dst++ = tiff->colormap[c + maxval] >> 8;
 				*dst++ = tiff->colormap[c + maxval * 2] >> 8;
-				*dst++ = a << (8 - tiff->bitspersample);
+				if (tiff->bitspersample <= 8)
+					*dst++ = a << (8 - tiff->bitspersample);
+				else
+					*dst++ = a >> (tiff->bitspersample - 8);
 			}
 			else
 			{
-- 
2.31.1

openSUSE Build Service is sponsored by