summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-20 11:54:02 +0000
committerRobin Watts <robin.watts@artifex.com>2012-01-20 16:55:41 +0000
commit8e59740d3ac9e6cdcc08baf1745f0808f2dc9df5 (patch)
tree8f14c985ab7e29e932b3c226e0754a6b6943594f
parent33d225213dac1217a86c00d0e8e8ca6d7503cbb2 (diff)
downloadmupdf-8e59740d3ac9e6cdcc08baf1745f0808f2dc9df5.tar.xz
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.
-rw-r--r--fitz/base_memory.c6
-rw-r--r--fitz/res_store.c4
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;
}
}