shithub: pdffs

Download patch

ref: 886a60cfed3741be9dc78b6eb4afdaedb88d6ed3
parent: 46473dabaa54037f2d0376653dfab75ff3c03301
author: Noam Preil <noam@pixelhero.dev>
date: Thu Apr 7 12:04:22 EDT 2022

gs: prevent double-free

--- a/op.c
+++ b/op.c
@@ -1258,12 +1258,14 @@
 pagegsclean(Page *p)
 {
 	int i;
-	p->GSactive = nil;
-	for(i = 0; i < p->nGS; i += 1)
-		gsfree(p->GS[i]);
-	free(p->GS);
-	p->GS = nil;
-	p->nGS = 0;
+	if(p->GSactive != nil){
+		p->GSactive = nil;
+		for(i = 0; i < p->nGS; i += 1)
+			gsfree(p->GS[i]);
+		free(p->GS);
+		p->GS = nil;
+		p->nGS = 0;
+	}
 }
 
 static int