summaryrefslogtreecommitdiff
path: root/source/fitz/colorspace.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-10-01 18:06:16 +0800
committerSebastian Rasmussen <sebras@gmail.com>2018-10-12 15:50:49 +0800
commitf3da0a43f59d0d49a912f46c51f44432087d782a (patch)
tree910c98611f3d7c289663e3e8467116749c1d9f5c /source/fitz/colorspace.c
parentebf7c785547cea1d3a15101d03104a10bb9947ed (diff)
downloadmupdf-f3da0a43f59d0d49a912f46c51f44432087d782a.tar.xz
Keep cmm instance around until all colorspaces have been dropped.
By setting ctx->cmm_instance == NULL we actively made sure that fz_cmm_fin_profile() would never call ->fin_profile() to actually clean up the ICC profiles. This could be triggered by doing mutool draw -N even without a file name, triggering a memory leak.
Diffstat (limited to 'source/fitz/colorspace.c')
-rw-r--r--source/fitz/colorspace.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 27072a49..55f2f080 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -835,7 +835,6 @@ void fz_set_cmm_engine(fz_context *ctx, const fz_cmm_engine *engine)
if (cct->cmm == engine)
return;
- fz_drop_cmm_context(ctx);
fz_drop_colorspace(ctx, cct->gray);
fz_drop_colorspace(ctx, cct->rgb);
fz_drop_colorspace(ctx, cct->bgr);
@@ -846,8 +845,12 @@ void fz_set_cmm_engine(fz_context *ctx, const fz_cmm_engine *engine)
cct->bgr = NULL;
cct->cmyk = NULL;
cct->lab = NULL;
+
+ fz_drop_cmm_context(ctx);
cct->cmm = engine;
+
fz_new_cmm_context(ctx);
+
if (engine)
{
cct->gray = fz_new_icc_colorspace(ctx, FZ_COLORSPACE_GRAY, NULL);