shithub: pdffs

Download patch

ref: 9961d1c13446442ca866353187b0e747cca2095f
parent: 7b9490c36eed8a9545890a108e003c5b0e57a39f
author: Noam Preil <[email protected]>
date: Fri Apr 8 20:02:32 EDT 2022

cs: initialize color when color space is set

--- a/op.c
+++ b/op.c
@@ -364,6 +364,7 @@
 cspace(Op *op, Page *p)
 {
 	ColorSpace *c = (op->flags & Nonstroking) ? &p->GSactive->NSCS : &p->GSactive->SCS;
+	u32int *color = (op->flags & Nonstroking) ? &p->GSactive->NSC : &p->GSactive->SC;
 	char *s = arrayget(p->stack, 0)->name;
 	Object *o;
 	int i;
@@ -370,6 +371,7 @@
 	for(i = 0; i < 3; i += 1)
 		if(strcmp(s, colorspacedevices[i]) == 0){
 			*c = i;
+			*color = i == 2 ? 0xFF : 0;
 			return 1;
 		}
 	if((o = dictget(dictget(p->obj, "Resources"), "ColorSpace")) == &null
@@ -380,7 +382,10 @@
 	if(strcmp(arrayget(o, 0)->name, "ICCBased") == 0){
 		/* Don't support ICC; fall back to Alternate or default */
 		o = arrayget(o, 1);
-		return iccbasedcspace(o, c);
+		if(!iccbasedcspace(o, c))
+			return 0;
+		*color = *c == 2 ? 0xFF : 0;
+		return 1;
 	}
 	werrstr("cspace: TODO: %s color space", arrayget(o, 0)->name);
 	return 0;