summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fitz/base_context.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fitz/base_context.c b/fitz/base_context.c
index 55d74cc3..ea67e0be 100644
--- a/fitz/base_context.c
+++ b/fitz/base_context.c
@@ -87,6 +87,8 @@ fz_new_context(fz_alloc_context *alloc, fz_locks_context *locks, unsigned int ma
locks = &fz_locks_default;
ctx = new_context_phase1(alloc, locks);
+ if (!ctx)
+ return NULL;
/* Now initialise sections that are shared */
fz_try(ctx)
@@ -121,9 +123,14 @@ fz_clone_context_internal(fz_context *ctx)
if (ctx == NULL || ctx->alloc == NULL)
return NULL;
+
new_ctx = new_context_phase1(ctx->alloc, ctx->locks);
+ if (!new_ctx)
+ return NULL;
+
/* Inherit AA defaults from old context. */
fz_copy_aa_context(new_ctx, ctx);
+
/* Keep thread lock checking happy by copying pointers first and locking under new context */
new_ctx->store = ctx->store;
new_ctx->store = fz_keep_store_context(new_ctx);
@@ -131,5 +138,6 @@ fz_clone_context_internal(fz_context *ctx)
new_ctx->glyph_cache = fz_keep_glyph_cache(new_ctx);
new_ctx->font = ctx->font;
new_ctx->font = fz_keep_font_context(new_ctx);
+
return new_ctx;
}