libzip: libzip-discuss: Memory Leak

Thread

Thread Index

  • Memory Leak, Simon Talbot (2010/01/29 00:50:20)

Message

From: Simon Talbot <simont%nse.co.uk@localhost>
To: "libzip-discuss%nih.at@localhost" <libzip-discuss%nih.at@localhost>
Subject: Memory Leak
Date: Fri, 29 Jan 2010 00:50:19 +0000

Please see patch below for a memory leak due to a missing free for the array of 
filelist structures malloced in zip_close. I have put it where it seems to make 
the most sense, but you will probably want to double check as I am not overly 
familiar with the code design.


diff -uNr libzip-0.9.1.orig/lib/zip_close.c libzip-0.9.1/lib/zip_close.c
--- libzip-0.9.1.orig/lib/zip_close.c   2008-07-02 13:58:09.000000000 +0100
+++ libzip-0.9.1/lib/zip_close.c        2010-01-28 22:50:43.000000000 +0000
@@ -310,7 +310,11 @@

     _zip_free(za);
     free(temp);
-
+
+    // NSE - SAT 20100128 - Bugfix to prevent memory leak by failure to free
+    // The array of filelist structures that was malloced at the start of this 
function
+    free(filelist);
+
     return 0;
 }

Best regards,

Simon

Simon Talbot MEng, ACGI 
(Chief Engineer) 
Tel: 020 3161 6001
Fax: 020 3161 6011

The information contained in this e-mail and any attachments are private 
and confidential and may be legally privileged. 

It is intended for the named addressee(s) only. If you are not the 
intended recipient(s), you must not read, copy or use the information 
contained in any way. If you receive this email or any attachments in 
error, please notify us immediately by e-mail and destroy any copy you 
have of it. 

We accept no responsibility for any loss or damages whatsoever arising 
in any way from receipt or use of this e-mail or any attachments. This 
e-mail is not intended to create legally binding commitments on our 
behalf, nor do its comments reflect our corporate views or policies.

Made by MHonArc.