shithub: libmujs

Download patch

ref: 86feee5b7b00b36758bb81ca3614daf61b99fc3c
parent: eafe79436d9ac4b0e324c3a0a0d1c4a373b2ccd3
author: Tor Andersson <tor.andersson@artifex.com>
date: Fri Dec 23 11:13:18 EST 2016

Pacify valgrind: it doesn't know realloc(p, 0) is equivalent to free(p).

--- a/jsstate.c
+++ b/jsstate.c
@@ -9,6 +9,10 @@
 
 static void *js_defaultalloc(void *actx, void *ptr, int size)
 {
+	if (size == 0) {
+		free(ptr);
+		return NULL;
+	}
 	return realloc(ptr, (size_t)size);
 }