[poppler] poppler/Form.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jan 2 23:02:20 UTC 2021


 poppler/Form.cc |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 7e4ec140d1cc6bef375e38f3cf3f613dd7c88bbb
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Jan 2 23:53:32 2021 +0100

    FormWidgetSignature::signDocument: Fix resource leak if something goes wrong

diff --git a/poppler/Form.cc b/poppler/Form.cc
index b1ba7df3..5ee2d514 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -564,6 +564,7 @@ bool FormWidgetSignature::signDocument(const char *saveFilename, const char *cer
     FILE *file = openFile(saveFilename, "r+b");
     if (!updateOffsets(file, objStart, objEnd, &sigStart, &sigEnd, &fileSize)) {
         fprintf(stderr, "signDocument: unable update byte range\n");
+        fclose(file);
         return false;
     }
 
@@ -574,12 +575,15 @@ bool FormWidgetSignature::signDocument(const char *saveFilename, const char *cer
 
     // and sign it
     const std::unique_ptr<GooString> signature = sigHandler.signDetached(password);
-    if (!signature)
+    if (!signature) {
+        fclose(file);
         return false;
+    }
 
     // write signature to saved file
     if (!updateSignature(file, sigStart, sigEnd, signature.get())) {
         fprintf(stderr, "signDocument: unable update signature\n");
+        fclose(file);
         return false;
     }
     signatureField->setSignature(*signature);


More information about the poppler mailing list