[PATCH] Fix resource leak

Joshua Rogers git at internot.info
Sun Jan 25 20:12:18 CET 2015


* kbx/keybox-update.c: Fix resource leak of in blob_filecopy
command. On return, it 'fp', and 'newfp' was never closed.

--

Signed-off-by: Joshua Rogers <git at internot.info>
---
 kbx/keybox-update.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kbx/keybox-update.c b/kbx/keybox-update.c
index 11861ac..4be1377 100644
--- a/kbx/keybox-update.c
+++ b/kbx/keybox-update.c
@@ -340,8 +340,11 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
   if ( mode == FILECOPY_INSERT || mode == FILECOPY_UPDATE )
     {
       rc = _keybox_write_blob (blob, newfp);
-      if (rc)
+      if (rc) {
+          fclose (fp);
+          fclose (newfp);
           return rc;
+      }
     }
 
   /* Copy the rest of the packet for an delete or update. */
-- 
1.9.1




More information about the Gnupg-devel mailing list