diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2012-08-04 19:34:09 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2012-08-06 13:59:20 +0200 |
commit | 0df1f84bd59e94798a09b55aac1d7cba40be60d0 (patch) | |
tree | 2c402ccc3f9c376bfb4a37ffa8b20e7e4cfa2c50 | |
parent | 4c00e74b4124474a736678e5554f9d8057c78de8 (diff) | |
download | mupdf-0df1f84bd59e94798a09b55aac1d7cba40be60d0.tar.xz |
No need to check for NULL before dropping objects
-rw-r--r-- | pdf/pdf_annot.c | 3 | ||||
-rw-r--r-- | pdf/pdf_crypt.c | 4 | ||||
-rw-r--r-- | pdf/pdf_interpret.c | 3 | ||||
-rw-r--r-- | pdf/pdf_object.c | 12 | ||||
-rw-r--r-- | pdf/pdf_page.c | 6 | ||||
-rw-r--r-- | pdf/pdf_repair.c | 27 | ||||
-rw-r--r-- | pdf/pdf_write.c | 9 | ||||
-rw-r--r-- | pdf/pdf_xobject.c | 6 | ||||
-rw-r--r-- | pdf/pdf_xref.c | 12 |
9 files changed, 30 insertions, 52 deletions
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c index f6c70f90..d6b5096e 100644 --- a/pdf/pdf_annot.c +++ b/pdf/pdf_annot.c @@ -320,8 +320,7 @@ pdf_free_annot(fz_context *ctx, pdf_annot *annot) next = annot->next; if (annot->ap) pdf_drop_xobject(ctx, annot->ap); - if (annot->obj) - pdf_drop_obj(annot->obj); + pdf_drop_obj(annot->obj); fz_free(ctx, annot); annot = next; } diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c index a8f92823..4fc34ea8 100644 --- a/pdf/pdf_crypt.c +++ b/pdf/pdf_crypt.c @@ -255,8 +255,8 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id) void pdf_free_crypt(fz_context *ctx, pdf_crypt *crypt) { - if (crypt->id) pdf_drop_obj(crypt->id); - if (crypt->cf) pdf_drop_obj(crypt->cf); + pdf_drop_obj(crypt->id); + pdf_drop_obj(crypt->cf); fz_free(ctx, crypt); } diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 0ecb7893..d8b8b9bc 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -996,8 +996,7 @@ pdf_clear_stack(pdf_csi *csi) { int i; - if (csi->obj) - pdf_drop_obj(csi->obj); + pdf_drop_obj(csi->obj); csi->obj = NULL; csi->name[0] = 0; diff --git a/pdf/pdf_object.c b/pdf/pdf_object.c index 7021fa5d..955cd5cf 100644 --- a/pdf/pdf_object.c +++ b/pdf/pdf_object.c @@ -512,8 +512,7 @@ pdf_array_put(pdf_obj *obj, int i, pdf_obj *item) fz_warn(obj->ctx, "assert: index %d > length %d", i, obj->u.a.len); else { - if (obj->u.a.items[i]) - pdf_drop_obj(obj->u.a.items[i]); + pdf_drop_obj(obj->u.a.items[i]); obj->u.a.items[i] = pdf_keep_obj(item); } } @@ -1090,8 +1089,7 @@ pdf_free_array(pdf_obj *obj) int i; for (i = 0; i < obj->u.a.len; i++) - if (obj->u.a.items[i]) - pdf_drop_obj(obj->u.a.items[i]); + pdf_drop_obj(obj->u.a.items[i]); fz_free(obj->ctx, obj->u.a.items); fz_free(obj->ctx, obj); @@ -1103,10 +1101,8 @@ pdf_free_dict(pdf_obj *obj) int i; for (i = 0; i < obj->u.d.len; i++) { - if (obj->u.d.items[i].k) - pdf_drop_obj(obj->u.d.items[i].k); - if (obj->u.d.items[i].v) - pdf_drop_obj(obj->u.d.items[i].v); + pdf_drop_obj(obj->u.d.items[i].k); + pdf_drop_obj(obj->u.d.items[i].v); } fz_free(obj->ctx, obj->u.d.items); diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c index 28be312d..4aa0a893 100644 --- a/pdf/pdf_page.c +++ b/pdf/pdf_page.c @@ -404,10 +404,8 @@ pdf_load_links(pdf_document *xref, pdf_page *page) void pdf_free_page(pdf_document *xref, pdf_page *page) { - if (page->resources) - pdf_drop_obj(page->resources); - if (page->contents) - pdf_drop_obj(page->contents); + pdf_drop_obj(page->resources); + pdf_drop_obj(page->contents); if (page->links) fz_drop_link(xref->ctx, page->links); if (page->annots) diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index df8d81f9..bbe70a2a 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -54,16 +54,14 @@ pdf_repair_obj(fz_stream *file, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, pdf obj = pdf_dict_gets(dict, "Encrypt"); if (obj) { - if (*encrypt) - pdf_drop_obj(*encrypt); + pdf_drop_obj(*encrypt); *encrypt = pdf_keep_obj(obj); } obj = pdf_dict_gets(dict, "ID"); if (obj) { - if (*id) - pdf_drop_obj(*id); + pdf_drop_obj(*id); *id = pdf_keep_obj(obj); } } @@ -363,32 +361,28 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf) obj = pdf_dict_gets(dict, "Encrypt"); if (obj) { - if (encrypt) - pdf_drop_obj(encrypt); + pdf_drop_obj(encrypt); encrypt = pdf_keep_obj(obj); } obj = pdf_dict_gets(dict, "ID"); if (obj) { - if (id) - pdf_drop_obj(id); + pdf_drop_obj(id); id = pdf_keep_obj(obj); } obj = pdf_dict_gets(dict, "Root"); if (obj) { - if (root) - pdf_drop_obj(root); + pdf_drop_obj(root); root = pdf_keep_obj(obj); } obj = pdf_dict_gets(dict, "Info"); if (obj) { - if (info) - pdf_drop_obj(info); + pdf_drop_obj(info); info = pdf_keep_obj(obj); } @@ -490,16 +484,17 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf) } pdf_dict_puts(xref->trailer, "ID", id); pdf_drop_obj(id); + id = NULL; } fz_free(ctx, list); } fz_catch(ctx) { - if (encrypt) pdf_drop_obj(encrypt); - if (id) pdf_drop_obj(id); - if (root) pdf_drop_obj(root); - if (info) pdf_drop_obj(info); + pdf_drop_obj(encrypt); + pdf_drop_obj(id); + pdf_drop_obj(root); + pdf_drop_obj(info); fz_free(ctx, list); fz_rethrow(ctx); } diff --git a/pdf/pdf_write.c b/pdf/pdf_write.c index 76f19748..3dce3838 100644 --- a/pdf/pdf_write.c +++ b/pdf/pdf_write.c @@ -735,8 +735,7 @@ static void renumberobjs(pdf_document *xref, pdf_write_options *opts) } else { - if (oldxref[num].obj) - pdf_drop_obj(oldxref[num].obj); + pdf_drop_obj(oldxref[num].obj); } } } @@ -1435,10 +1434,8 @@ static void addhexfilter(pdf_document *xref, pdf_obj *dict) pdf_drop_obj(ahx); pdf_drop_obj(nullobj); - if (newf) - pdf_drop_obj(newf); - if (newdp) - pdf_drop_obj(newdp); + pdf_drop_obj(newf); + pdf_drop_obj(newdp); } static void copystream(pdf_document *xref, pdf_write_options *opts, pdf_obj *obj_orig, int num, int gen) diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c index f21ecaf6..c5fc2a83 100644 --- a/pdf/pdf_xobject.c +++ b/pdf/pdf_xobject.c @@ -20,10 +20,8 @@ pdf_free_xobject_imp(fz_context *ctx, fz_storable *xobj_) if (xobj->colorspace) fz_drop_colorspace(ctx, xobj->colorspace); - if (xobj->resources) - pdf_drop_obj(xobj->resources); - if (xobj->contents) - pdf_drop_obj(xobj->contents); + pdf_drop_obj(xobj->resources); + pdf_drop_obj(xobj->contents); pdf_drop_obj(xobj->me); fz_free(ctx, xobj); } diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index 6a7585bd..4d3c32b8 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -551,8 +551,7 @@ pdf_ocg_set_config(pdf_document *xref, int config) fz_throw(xref->ctx, "Illegal OCG config"); } - if (desc->intent) - pdf_drop_obj(desc->intent); + pdf_drop_obj(desc->intent); desc->intent = pdf_dict_gets(cobj, "Intent"); if (desc->intent) pdf_keep_obj(desc->intent); @@ -677,8 +676,7 @@ pdf_free_ocg(fz_context *ctx, pdf_ocg_descriptor *desc) if (!desc) return; - if (desc->intent) - pdf_drop_obj(desc->intent); + pdf_drop_obj(desc->intent); fz_free(ctx, desc->ocgs); fz_free(ctx, desc); } @@ -845,8 +843,7 @@ pdf_close_document(pdf_document *xref) if (xref->file) fz_close(xref->file); - if (xref->trailer) - pdf_drop_obj(xref->trailer); + pdf_drop_obj(xref->trailer); if (xref->crypt) pdf_free_crypt(ctx, xref->crypt); @@ -1154,8 +1151,7 @@ pdf_update_object(pdf_document *xref, int num, pdf_obj *newobj) x = &xref->table[num]; - if (x->obj) - pdf_drop_obj(x->obj); + pdf_drop_obj(x->obj); x->type = 'n'; x->ofs = 0; |