From ce82537df9e4b832213138d942be4482418b9e50 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sat, 15 Oct 2016 01:55:05 +0800 Subject: All external drop functions handles NULL. --- source/fitz/hash.c | 3 +++ source/fitz/image.c | 3 +++ source/fitz/link.c | 3 +++ source/fitz/pool.c | 7 ++++++- source/fitz/writer.c | 3 +++ source/fitz/zip.c | 2 ++ source/html/html-font.c | 3 +++ source/pdf/pdf-resources.c | 7 +++++-- 8 files changed, 28 insertions(+), 3 deletions(-) diff --git a/source/fitz/hash.c b/source/fitz/hash.c index 31a692c0..e16aefd1 100644 --- a/source/fitz/hash.c +++ b/source/fitz/hash.c @@ -96,6 +96,9 @@ fz_hash_get_val(fz_context *ctx, fz_hash_table *table, int idx) void fz_drop_hash(fz_context *ctx, fz_hash_table *table) { + if (!table) + return; + fz_free(ctx, table->ents); fz_free(ctx, table); } diff --git a/source/fitz/image.c b/source/fitz/image.c index 48420a81..7373147f 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -376,6 +376,9 @@ fz_drop_image_imp(fz_context *ctx, fz_storable *image_) void fz_drop_image_base(fz_context *ctx, fz_image *image) { + if (!image) + return; + fz_drop_colorspace(ctx, image->colorspace); fz_drop_image(ctx, image->mask); fz_free(ctx, image); diff --git a/source/fitz/link.c b/source/fitz/link.c index 20668ab1..eaed1402 100644 --- a/source/fitz/link.c +++ b/source/fitz/link.c @@ -3,6 +3,9 @@ void fz_drop_link_dest(fz_context *ctx, fz_link_dest *dest) { + if (!dest) + return; + switch (dest->kind) { case FZ_LINK_NONE: diff --git a/source/fitz/pool.c b/source/fitz/pool.c index 2591c563..90c405dc 100644 --- a/source/fitz/pool.c +++ b/source/fitz/pool.c @@ -41,7 +41,12 @@ char *fz_pool_strdup(fz_context *ctx, fz_pool *pool, const char *s) void fz_drop_pool(fz_context *ctx, fz_pool *pool) { - fz_pool_node *node = pool->head; + fz_pool_node *node; + + if (!pool) + return; + + node = pool->head; while (node) { fz_pool_node *next = node->next; diff --git a/source/fitz/writer.c b/source/fitz/writer.c index d7fd60f9..fe9e8635 100644 --- a/source/fitz/writer.c +++ b/source/fitz/writer.c @@ -82,6 +82,9 @@ fz_close_document_writer(fz_context *ctx, fz_document_writer *wri) void fz_drop_document_writer(fz_context *ctx, fz_document_writer *wri) { + if (!wri) + return; + if (wri->close_writer) fz_warn(ctx, "dropping unclosed document writer"); if (wri->drop_writer) diff --git a/source/fitz/zip.c b/source/fitz/zip.c index 599d2954..95f1bd03 100644 --- a/source/fitz/zip.c +++ b/source/fitz/zip.c @@ -87,6 +87,8 @@ fz_close_zip_writer(fz_context *ctx, fz_zip_writer *zip) void fz_drop_zip_writer(fz_context *ctx, fz_zip_writer *zip) { + if (!zip) + return; if (!zip->closed) fz_warn(ctx, "dropping unclosed zip writer"); fz_drop_output(ctx, zip->output); diff --git a/source/html/html-font.c b/source/html/html-font.c index 01ec10f5..48c04b73 100644 --- a/source/html/html-font.c +++ b/source/html/html-font.c @@ -86,6 +86,9 @@ void fz_drop_html_font_set(fz_context *ctx, fz_html_font_set *set) fz_html_font_face *font, *next; int i; + if (!set) + return; + font = set->custom; while (font) { diff --git a/source/pdf/pdf-resources.c b/source/pdf/pdf-resources.c index 7c1f36ad..ad195393 100644 --- a/source/pdf/pdf-resources.c +++ b/source/pdf/pdf-resources.c @@ -147,6 +147,9 @@ res_table_free(fz_context *ctx, fz_hash_table *hash) void pdf_drop_resource_tables(fz_context *ctx, pdf_document *doc) { - res_table_free(ctx, doc->resources.fonts); - res_table_free(ctx, doc->resources.images); + if (doc) + { + res_table_free(ctx, doc->resources.fonts); + res_table_free(ctx, doc->resources.images); + } } -- cgit v1.2.3