summaryrefslogtreecommitdiff
path: root/source/tools/murun.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2017-10-29 13:15:04 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-11-22 23:09:51 +0100
commite0ecb56e43727e25c3d9838ff98244d7c47a4c81 (patch)
treec7429a0ae7b90598a57534e772bb5ce522d9880b /source/tools/murun.c
parent0341de323d93bb6f7344dd381690e04314cbd9ae (diff)
downloadmupdf-e0ecb56e43727e25c3d9838ff98244d7c47a4c81.tar.xz
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.
Diffstat (limited to 'source/tools/murun.c')
-rw-r--r--source/tools/murun.c8
1 files changed, 6 insertions, 2 deletions
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)