From 5d70d34fb639e8f46bb9246d84020f9e3b307b6a Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 12 Jul 2016 13:04:28 +0200 Subject: js: Fix memory leak in new Image(). --- source/tools/murun.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/tools/murun.c b/source/tools/murun.c index fb35f0a0..bf329540 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -550,6 +550,12 @@ static void ffi_pushimage(js_State *J, fz_image *image) js_newuserdata(J, "fz_image", fz_keep_image(ctx, image), ffi_gc_fz_image); } +static void ffi_pushimage_own(js_State *J, fz_image *image) +{ + js_getregistry(J, "fz_image"); + js_newuserdata(J, "fz_image", image, ffi_gc_fz_image); +} + static int is_number(const char *key, int *idx) { char *end; @@ -1851,7 +1857,7 @@ static void ffi_new_Image(js_State *J) rethrow(J); } - ffi_pushimage(J, image); + ffi_pushimage_own(J, image); } static void ffi_Image_getWidth(js_State *J) -- cgit v1.2.3