From 8e59740d3ac9e6cdcc08baf1745f0808f2dc9df5 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 20 Jan 2012 11:54:02 +0000 Subject: Fix locking problems. Thanks to filmor's help, fix some problems where locking was going wrong; in 2 cases we failed to unlock, and in 2 cases we tried to free (which relocks) while already locked. All simple fixes. --- fitz/base_memory.c | 6 ++++++ fitz/res_store.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fitz/base_memory.c b/fitz/base_memory.c index c9b94f1e..776bdce6 100644 --- a/fitz/base_memory.c +++ b/fitz/base_memory.c @@ -10,7 +10,10 @@ do_scavenging_malloc(fz_context *ctx, unsigned int size) do { p = ctx->alloc->malloc(ctx->alloc->user, size); if (p != NULL) + { + fz_unlock(ctx); return p; + } } while (fz_store_scavenge(ctx, size, &phase)); fz_unlock(ctx); @@ -27,7 +30,10 @@ do_scavenging_realloc(fz_context *ctx, void *p, unsigned int size) do { q = ctx->alloc->realloc(ctx->alloc->user, p, size); if (q != NULL) + { + fz_unlock(ctx); return q; + } } while (fz_store_scavenge(ctx, size, &phase)); fz_unlock(ctx); diff --git a/fitz/res_store.c b/fitz/res_store.c index 93d48272..3ee910cc 100644 --- a/fitz/res_store.c +++ b/fitz/res_store.c @@ -196,8 +196,8 @@ fz_store_item(fz_context *ctx, fz_obj *key, void *val_, unsigned int itemsize) size = store->size + itemsize; if (store->max != FZ_STORE_UNLIMITED && size > store->max && ensure_space(ctx, size - store->max)) { - fz_free(ctx, item); fz_unlock(ctx); + fz_free(ctx, item); return; } store->size += itemsize; @@ -220,8 +220,8 @@ fz_store_item(fz_context *ctx, fz_obj *key, void *val_, unsigned int itemsize) } fz_catch(ctx) { - fz_free(ctx, item); fz_unlock(ctx); + fz_free(ctx, item); return; } } -- cgit v1.2.3