shithub: pdffs

Download patch

ref: 1ecdb9da0d3e8ae0e6b6c49d4cfdea72355261a0
parent: 6237cc2a6834ccba99270c96dc66e4bffd3173a7
author: Noam Preil <noam@pixelhero.dev>
date: Thu Aug 5 15:56:39 EDT 2021

op: correctly initialize GSactive.

The graphics state can be pushed and popped. As such, in addition to the stack of the state, a pointer to the active state is kept at all times. While pushing and popping correctly updated the pointer, we were not previously initializing it on startup. While some PDFs - notably, ps2pdf output - worked without issues, other PDFs, which use the graphics state immediately, did not.

This commit resolves that issue by initializing GSactive to the initial graphics state when setting up the renderer.

--- a/op.c
+++ b/op.c
@@ -1252,6 +1252,7 @@
 		werrstr("Out of memory");
 		return 0;
 	}
+	p->GSactive = p->GS;
 	gsinit(p, p->GS);
 	content = dictget(p->obj, "Contents");
 	if(content->type == Oarray){