[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2331-gec281af
[email protected] (Nancy Durgin) Thu, 10 Oct 2019 21:13:44 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, pdfi has been updated
via ec281af848f863dd758006dc31d53d3c8b9fbdeb (commit)
from 23c2dc5ebbb1bcd8dd7ba4c06d156c57c2482c5a (commit)
----------------------------------------------------------------------
commit ec281af848f863dd758006dc31d53d3c8b9fbdeb
Author: Nancy Durgin <[email protected]>
Date: Thu Oct 10 13:23:03 2019 -0700
Fix memory leak in managing smask/client_data
Need to free the contents of old client_data before overwriting it.
(It was fine on gsave, was causing memory leak on grestore)
diff --git a/pdf/pdf_gstate.c b/pdf/pdf_gstate.c
index 535aeb2..8a063e2 100644
--- a/pdf/pdf_gstate.c
+++ b/pdf/pdf_gstate.c
@@ -68,6 +68,8 @@ void pdfi_gstate_smask_install(pdfi_int_gstate *igs, gs_memory_t *memory, pdf_di
void pdfi_gstate_smask_free(pdfi_int_gstate *igs)
{
+ if (!igs->SMask)
+ return;
pdfi_countdown(igs->SMask);
igs->SMask = NULL;
if (igs->GroupGState)
@@ -96,6 +98,10 @@ pdfi_gstate_copy_cb(void *to, const void *from)
const pdfi_int_gstate *igs_from = (const pdfi_int_gstate *)from;
pdfi_int_gstate *igs_to = (pdfi_int_gstate *)to;
+ /* Need to free destination contents before overwriting.
+ * On grestore, they might be non-empty.
+ */
+ pdfi_gstate_smask_free(igs_to);
*(pdfi_int_gstate *) igs_to = *igs_from;
pdfi_gstate_smask_install(igs_to, igs_from->memory, igs_from->SMask, igs_from->GroupGState);
return 0;
@@ -116,7 +122,7 @@ static const gs_gstate_client_procs pdfi_gstate_procs = {
pdfi_gstate_alloc_cb,
pdfi_gstate_copy_cb,
pdfi_gstate_free_cb,
- NULL, /* copy_for */
+ NULL, /* copy_for */
};
int
Summary of changes:
pdf/pdf_gstate.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)