shithub: libmujs

Download patch

ref: 720aec8cd4e92f3cbfd3e4d0fb3b463ecedffba7
parent: 9bc5fec0804381d59ef8dc62304ed6892fb7c4ca
author: Tor Andersson <tor.andersson@artifex.com>
date: Fri Jan 2 08:38:19 EST 2015

Fix memory leak when freeing js_State.

--- a/jsgc.c
+++ b/jsgc.c
@@ -218,6 +218,7 @@
 	js_Function *fun, *nextfun;
 	js_Object *obj, *nextobj;
 	js_Environment *env, *nextenv;
+	js_String *str, *nextstr;
 
 	for (env = J->gcenv; env; env = nextenv)
 		nextenv = env->gcnext, jsG_freeenvironment(J, env);
@@ -225,6 +226,8 @@
 		nextfun = fun->gcnext, jsG_freefunction(J, fun);
 	for (obj = J->gcobj; obj; obj = nextobj)
 		nextobj = obj->gcnext, jsG_freeobject(J, obj);
+	for (str = J->gcstr; str; str = nextstr)
+		nextstr = str->gcnext, js_free(J, str);
 
 	jsS_freestrings(J);