summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-03-14 15:02:35 +0000
committerRobin Watts <robin.watts@artifex.com>2012-03-14 15:41:00 +0000
commit215a89a88c095041b862d535943b9be579db6417 (patch)
tree25d7ce9869226d468aaaa0ec7d99d7c083a036a7 /pdf
parent7f830398abb77dd7a0c63f38ad3f36002f7d1629 (diff)
downloadmupdf-215a89a88c095041b862d535943b9be579db6417.tar.xz
Avoid NULL dereferences in error cases when trying to warn.
Spotted from SumatraMuPDF.patch. Many thanks.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/base_object.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/pdf/base_object.c b/pdf/base_object.c
index 460b89f2..00032fb8 100644
--- a/pdf/base_object.c
+++ b/pdf/base_object.c
@@ -454,7 +454,9 @@ pdf_copy_array(fz_context *ctx, pdf_obj *obj)
int n;
RESOLVE(obj);
- if (!obj || obj->kind != PDF_ARRAY)
+ if (!obj)
+ return NULL; /* Can't warn :( */
+ if (obj->kind != PDF_ARRAY)
fz_warn(ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
arr = pdf_new_array(ctx, pdf_array_len(obj));
@@ -623,7 +625,9 @@ pdf_copy_dict(fz_context *ctx, pdf_obj *obj)
int i, n;
RESOLVE(obj);
- if (obj && obj->kind != PDF_DICT)
+ if (!obj)
+ return NULL; /* Can't warn :( */
+ if (obj->kind != PDF_DICT)
fz_warn(ctx, "assert: not a dict (%s)", pdf_objkindstr(obj));
n = pdf_dict_len(obj);
@@ -756,7 +760,9 @@ fz_dict_put(pdf_obj *obj, pdf_obj *key, pdf_obj *val)
int i;
RESOLVE(obj);
- if (!obj || obj->kind != PDF_DICT)
+ if (!obj)
+ return; /* Can't warn :( */
+ if (obj->kind != PDF_DICT)
{
fz_warn(obj->ctx, "assert: not a dict (%s)", pdf_objkindstr(obj));
return;
@@ -816,7 +822,9 @@ pdf_dict_dels(pdf_obj *obj, char *key)
{
RESOLVE(obj);
- if (!obj || obj->kind != PDF_DICT)
+ if (!obj)
+ return; /* Can't warn :( */
+ if (obj->kind != PDF_DICT)
fz_warn(obj->ctx, "assert: not a dict (%s)", pdf_objkindstr(obj));
else
{