summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2012-08-23 13:48:50 +0100
committerPaul Gardiner <paulg.artifex@glidos.net>2012-08-23 13:48:50 +0100
commit241f109a66916bb4a5a8d3caa2167895e87b04ec (patch)
tree6b269912ca777d1c4144df5c6cdf8f9bd0510fc8 /pdf
parent4469e9e8f47313b7cdc3c1ea8760257641dbda7f (diff)
downloadmupdf-241f109a66916bb4a5a8d3caa2167895e87b04ec.tar.xz
Fix bug introduced in preceding commit
Not handling pdf_jsimp_toString returning NULL Throwing C exceptions in a call issued by v8 Iterating a pointer later used to free a buffer
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_js.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/pdf/pdf_js.c b/pdf/pdf_js.c
index a086b98c..1ce2c7e9 100644
--- a/pdf/pdf_js.c
+++ b/pdf/pdf_js.c
@@ -279,30 +279,38 @@ static pdf_jsimp_obj *doc_getField(void *jsctx, void *obj, int argc, pdf_jsimp_o
fz_context *ctx = js->doc->ctx;
pdf_obj *arr = js->form;
pdf_obj *dict = NULL;
- int len;
- char *utf8, *name, *dot;
+ int len;
+ char *utf8, *dot;
+ char *name = NULL;
+ char *namep;
if (argc != 1)
return NULL;
- /* Process the fully qualified field name which has
- * the partial names delimited by '.' */
- utf8 = pdf_jsimp_toString(js->imp, args[0]);
- name = utf8_to_pdf(ctx, utf8);
-
- /* Pretend there was a preceding '.' to simplify the loop */
- dot = name - 1;
-
+ fz_var(dict);
+ fz_var(name);
fz_try(ctx)
{
- while (dot && arr)
+ utf8 = pdf_jsimp_toString(js->imp, args[0]);
+
+ if (utf8)
{
- name = dot + 1;
- dot = strchr(name, '.');
- len = dot ? dot - name : strlen(name);
- dict = find_field(arr, name, len);
- if (dot)
- arr = pdf_dict_gets(dict, "Kids");
+ name = utf8_to_pdf(ctx, utf8);
+
+ /* Process the fully qualified field name which has
+ * the partial names delimited by '.'. Pretend there
+ * was a preceding '.' to simplify the loop */
+ dot = name - 1;
+
+ while (dot && arr)
+ {
+ namep = dot + 1;
+ dot = strchr(namep, '.');
+ len = dot ? dot - namep : strlen(namep);
+ dict = find_field(arr, namep, len);
+ if (dot)
+ arr = pdf_dict_gets(dict, "Kids");
+ }
}
}
fz_always(ctx)
@@ -311,7 +319,8 @@ static pdf_jsimp_obj *doc_getField(void *jsctx, void *obj, int argc, pdf_jsimp_o
}
fz_catch(ctx)
{
- fz_rethrow(ctx);
+ fz_warn(ctx, "doc_getField failed: %s", ctx->error->message);
+ dict = NULL;
}
return dict ? pdf_jsimp_new_obj(js->imp, js->fieldtype, dict) : NULL;