From e0ecb56e43727e25c3d9838ff98244d7c47a4c81 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 29 Oct 2017 13:15:04 +0100 Subject: js: Return undef when not finding metadata. Previously when metadata was not found mupdf still tried to return a string to the caller, but the string was uninitialized. --- source/tools/murun.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/tools') diff --git a/source/tools/murun.c b/source/tools/murun.c index ea66f0ac..6754b32e 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -1648,13 +1648,17 @@ static void ffi_Document_getMetaData(js_State *J) fz_document *doc = ffi_todocument(J, 0); const char *key = js_tostring(J, 1); char info[256]; + int found; fz_try(ctx) - fz_lookup_metadata(ctx, doc, key, info, sizeof info); + found = fz_lookup_metadata(ctx, doc, key, info, sizeof info); fz_catch(ctx) rethrow(J); - js_pushstring(J, info); + if (found) + js_pushstring(J, info); + else + js_pushundefined(J); } static void ffi_Document_isReflowable(js_State *J) -- cgit v1.2.3