diff options
author | Robin Watts <robin.watts@artifex.com> | 2017-03-31 14:18:02 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2017-03-31 14:57:38 +0100 |
commit | a0c30b512ff66fe18fdca0cd0eb240b60c95b42a (patch) | |
tree | 5f2b70826f280a326cedb96eef66f49200fff2c1 | |
parent | 4594d29875ce6cba8132e2051360b06131323c5b (diff) | |
download | mupdf-a0c30b512ff66fe18fdca0cd0eb240b60c95b42a.tar.xz |
Fix leaks of reaped object keys.
-rw-r--r-- | include/mupdf/fitz/store.h | 2 | ||||
-rw-r--r-- | source/fitz/image.c | 3 | ||||
-rw-r--r-- | source/fitz/store.c | 3 |
3 files changed, 5 insertions, 3 deletions
diff --git a/include/mupdf/fitz/store.h b/include/mupdf/fitz/store.h index a93fca47..57b817fc 100644 --- a/include/mupdf/fitz/store.h +++ b/include/mupdf/fitz/store.h @@ -58,7 +58,7 @@ void *fz_keep_key_storable(fz_context *, const fz_key_storable *); int fz_drop_key_storable(fz_context *, const fz_key_storable *); void *fz_keep_key_storable_key(fz_context *, const fz_key_storable *); -void fz_drop_key_storable_key(fz_context *, const fz_key_storable *); +int fz_drop_key_storable_key(fz_context *, const fz_key_storable *); static inline int fz_key_storable_needs_reaping(fz_context *ctx, const fz_key_storable *ks) { diff --git a/source/fitz/image.c b/source/fitz/image.c index 0906d9ad..2ee1cfbb 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -42,7 +42,8 @@ fz_keep_image_store_key(fz_context *ctx, fz_image *image) void fz_drop_image_store_key(fz_context *ctx, fz_image *image) { - fz_drop_key_storable_key(ctx, &image->key_storable); + if (fz_drop_key_storable_key(ctx, &image->key_storable)) + fz_free(ctx, image); } static int diff --git a/source/fitz/store.c b/source/fitz/store.c index dcef6b86..2013af8c 100644 --- a/source/fitz/store.c +++ b/source/fitz/store.c @@ -238,7 +238,7 @@ void *fz_keep_key_storable_key(fz_context *ctx, const fz_key_storable *sc) return s; } -void fz_drop_key_storable_key(fz_context *ctx, const fz_key_storable *sc) +int fz_drop_key_storable_key(fz_context *ctx, const fz_key_storable *sc) { /* Explicitly drop const to allow us to use const * sanely throughout the code. */ @@ -264,6 +264,7 @@ void fz_drop_key_storable_key(fz_context *ctx, const fz_key_storable *sc) */ if (drop) s->storable.drop(ctx, &s->storable); + return drop; } static void |