summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2022-08-18 16:48:46 +0100
committerKen Sharp <ken.sharp@artifex.com>2022-08-18 16:48:46 +0100
commit71484d8977bf79411dca9ebc6c9c1fcc36723ea7 (patch)
tree9b779d3871fe2b3913ce7ef1498f4c425bcb8191
parent1d8d9605e251d1b51281efe5ef8db07640e49203 (diff)
downloadghostpdl-71484d8977bf79411dca9ebc6c9c1fcc36723ea7.tar.gz
GhostPDF - fix memory leak with Widget annotations
Exhibited by /tests_private/pdf/sumatra/1348_-_support_Additional_Actions.pdf The problem can occur if we find either /T or /FT in the current dictionary but don't find both. In that case we try to find the keys in any /Parent dictionary. But if the Parent contains *both* keys then it would replace the stored one found in the earlier dictionary, without counting it down, leading to a memory leak. We don't actually use the /T and /FT values which we retrieve, so the simplest solution is to simply discard them as soon as they are found. Once we do that, we don't need to count them down on exit any more either.
-rw-r--r--pdf/pdf_annot.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c
index 7102837b6..fe65803f3 100644
--- a/pdf/pdf_annot.c
+++ b/pdf/pdf_annot.c
@@ -3661,6 +3661,8 @@ static int pdfi_annot_draw_Widget(pdf_context *ctx, pdf_dict *annot, pdf_obj *No
if (code < 0) goto exit;
if (code > 0) {
found_T = true;
+ pdfi_countdown(T);
+ T = NULL;
if (found_FT)
break;
}
@@ -3668,6 +3670,8 @@ static int pdfi_annot_draw_Widget(pdf_context *ctx, pdf_dict *annot, pdf_obj *No
if (code < 0) goto exit;
if (code > 0) {
found_FT = true;
+ pdfi_countdown(FT);
+ FT = NULL;
if (found_T)
break;
}
@@ -3719,8 +3723,6 @@ static int pdfi_annot_draw_Widget(pdf_context *ctx, pdf_dict *annot, pdf_obj *No
*render_done = true;
exit:
- pdfi_countdown(T);
- pdfi_countdown(FT);
pdfi_countdown(Parent);
pdfi_countdown(currdict);
return code;