summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-03-01 16:38:01 +0000
committerRobin Watts <robin.watts@artifex.com>2012-03-01 16:38:01 +0000
commitbcf7519882ba6f7b8f4b8047fb1f94bc9bd1ec6e (patch)
treed1442f846e9e46edac46d692f6044b9b1c85e660 /fitz
parentc6aa389a2c3430396a5e818bbb849410ab29d617 (diff)
downloadmupdf-bcf7519882ba6f7b8f4b8047fb1f94bc9bd1ec6e.tar.xz
Fix incorrect handling of race condition.
When inserting an item into the store we check for an identically keyed item being there already (for instance a pixmap created from an image I at factor F may find that such a pixmap has already been inserted). The correct thing to do is to return the old one so we can use that in preference. The code was attempting to do this, but was returning a pointer to the fz_item rather than to the item->val. Fixed here.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/res_store.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fitz/res_store.c b/fitz/res_store.c
index 8f9c1ad8..0e3e7214 100644
--- a/fitz/res_store.c
+++ b/fitz/res_store.c
@@ -248,7 +248,7 @@ fz_store_item(fz_context *ctx, void *key, void *val_, unsigned int itemsize, fz_
/* If we can index it fast, put it into the hash table */
if (use_hash)
{
- fz_pixmap *existing;
+ fz_item *existing;
fz_try(ctx)
{
@@ -265,7 +265,8 @@ fz_store_item(fz_context *ctx, void *key, void *val_, unsigned int itemsize, fz_
if (existing)
{
fz_unlock(ctx, FZ_LOCK_ALLOC);
- return existing;
+ fz_free(ctx, item);
+ return existing->val;
}
}
/* Now we can never fail, bump the ref */