summaryrefslogtreecommitdiff
path: root/source/fitz/load-pnm.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-10-24 16:00:54 +0200
committerRobin Watts <robin.watts@artifex.com>2017-10-25 10:58:36 +0100
commit531f7ea84daa607e370757d82d8bf7e300fc76b5 (patch)
treeb621cbb5797639a343e3b46d35ec842aa4450535 /source/fitz/load-pnm.c
parent75be08bcb490e9b68ef598372ff659ad960f6335 (diff)
downloadmupdf-531f7ea84daa607e370757d82d8bf7e300fc76b5.tar.xz
Fix colorspace reference counting in fz_load_*_info.
These are called from fz_new_image_from_buffer.
Diffstat (limited to 'source/fitz/load-pnm.c')
-rw-r--r--source/fitz/load-pnm.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/source/fitz/load-pnm.c b/source/fitz/load-pnm.c
index 0a1fa3f4..95c613c0 100644
--- a/source/fitz/load-pnm.c
+++ b/source/fitz/load-pnm.c
@@ -623,35 +623,18 @@ pnm_read_image(fz_context *ctx, struct info *pnm, const unsigned char *p, size_t
fz_pixmap *
fz_load_pnm(fz_context *ctx, const unsigned char *p, size_t total)
{
- fz_pixmap *img = NULL;
struct info pnm = { 0 };
-
- fz_try(ctx)
- img = pnm_read_image(ctx, &pnm, p, total, 0);
- fz_always(ctx)
- fz_drop_colorspace(ctx, pnm.cs);
- fz_catch(ctx)
- fz_rethrow(ctx);
-
- return img;
+ return pnm_read_image(ctx, &pnm, p, total, 0);
}
void
fz_load_pnm_info(fz_context *ctx, const unsigned char *p, size_t total, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
struct info pnm = { 0 };
-
- fz_try(ctx)
- {
- pnm_read_image(ctx, &pnm, p, total, 1);
- *cspacep = pnm.cs;
- *wp = pnm.width;
- *hp = pnm.height;
- *xresp = 72;
- *yresp = 72;
- }
- fz_always(ctx)
- fz_drop_colorspace(ctx, pnm.cs);
- fz_catch(ctx)
- fz_rethrow(ctx);
+ (void) pnm_read_image(ctx, &pnm, p, total, 1);
+ *cspacep = fz_keep_colorspace(ctx, pnm.cs); /* pnm.cs is a borrowed device colorspace */
+ *wp = pnm.width;
+ *hp = pnm.height;
+ *xresp = 72;
+ *yresp = 72;
}