shithub: pdffs

Download patch

ref: b2307140ac624a7a3ab9a84b761031f5ead84888
parent: a01e30542bfd8d8e1e307e71f4600619a18cacd1
author: Noam Preil <noam@pixelhero.dev>
date: Tue Sep 6 22:47:32 EDT 2022

parse: ensure room for null byte

--- a/string.c
+++ b/string.c
@@ -134,6 +134,10 @@
 	}
 
 	if(c >= 0 && (o = malloc(sizeof(*o))) != nil){
+		sz += 1;
+		if((r = realloc(s, sz)) == nil)
+				goto err;
+		s = r;
 		s[sz] = 0;
 		o->str = s;
 		o->len = sz;