diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-10-01 18:06:16 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-10-12 15:50:49 +0800 |
commit | f3da0a43f59d0d49a912f46c51f44432087d782a (patch) | |
tree | 910c98611f3d7c289663e3e8467116749c1d9f5c /source | |
parent | ebf7c785547cea1d3a15101d03104a10bb9947ed (diff) | |
download | mupdf-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')
-rw-r--r-- | source/fitz/colorspace.c | 5 |
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); |