1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #18890 from calixteman/clamp_indexedcs_hival

Clamp the hival parameter of Indexed color space to the range [0; 255]
This commit is contained in:
calixteman 2024-10-12 23:53:59 +02:00 committed by GitHub
commit 1c0c070847
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -462,7 +462,7 @@ class ColorSpace {
case "I":
case "Indexed":
baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
const hiVal = xref.fetchIfRef(cs[2]) + 1;
const hiVal = Math.max(0, Math.min(xref.fetchIfRef(cs[2]), 255));
const lookup = xref.fetchIfRef(cs[3]);
return new IndexedCS(baseCS, hiVal, lookup);
case "Separation":
@ -630,9 +630,8 @@ class IndexedCS extends ColorSpace {
constructor(base, highVal, lookup) {
super("Indexed", 1);
this.base = base;
this.highVal = highVal;
const length = base.numComps * highVal;
const length = base.numComps * (highVal + 1);
this.lookup = new Uint8Array(length);
if (lookup instanceof BaseStream) {