1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 0C196431FAF
\r
6 for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 14:21:28 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id aIHGFXBTVUFq for <notmuch@notmuchmail.org>;
\r
16 Mon, 6 Feb 2012 14:21:27 -0800 (PST)
\r
17 Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com
\r
18 [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 275BE431FAE
\r
21 for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 14:21:27 -0800 (PST)
\r
22 Received: by lahd3 with SMTP id d3so3964852lah.26
\r
23 for <notmuch@notmuchmail.org>; Mon, 06 Feb 2012 14:21:25 -0800 (PST)
\r
24 Received: by 10.152.146.163 with SMTP id td3mr109516lab.31.1328566885702;
\r
25 Mon, 06 Feb 2012 14:21:25 -0800 (PST)
\r
26 Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.
\r
28 by mx.google.com with ESMTPS id j4sm14067691lbf.6.2012.02.06.14.21.23
\r
29 (version=SSLv3 cipher=OTHER); Mon, 06 Feb 2012 14:21:24 -0800 (PST)
\r
30 From: Jani Nikula <jani@nikula.org>
\r
31 To: Ethan Glasser-Camp <glasse@cs.rpi.edu>, notmuch@notmuchmail.org
\r
32 Subject: Re: [PATCH] Free the results of scandir()
\r
33 In-Reply-To: <1328565769-29414-1-git-send-email-glasse@cs.rpi.edu>
\r
34 References: <1328565769-29414-1-git-send-email-glasse@cs.rpi.edu>
\r
35 User-Agent: Notmuch/0.11+139~g4340989 (http://notmuchmail.org) Emacs/23.3.1
\r
37 Date: Tue, 07 Feb 2012 00:21:21 +0200
\r
38 Message-ID: <878vkfppr2.fsf@nikula.org>
\r
40 Content-Type: text/plain; charset=us-ascii
\r
41 Cc: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Mon, 06 Feb 2012 22:21:28 -0000
\r
56 On Mon, 6 Feb 2012 17:02:49 -0500, Ethan Glasser-Camp <glasse@cs.rpi.edu> wrote:
\r
57 > From: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
59 > scandir() returns "strings allocated via malloc(3)" which are then
\r
60 > "collected in array namelist which is allocated via
\r
61 > malloc(3)". Currently we just free the array namelist. Instead, free
\r
62 > all the entries of namelist, and then free namelist.
\r
64 > entry only points to elements of namelist, so we don't free it
\r
68 > This should fix a minor memory leak in notmuch-new. Please confirm I'm
\r
69 > reading the manpage correctly ;)
\r
71 It looks right, good catch! Please do also fix the other scandir() usage
\r
79 > notmuch-new.c | 8 +++++---
\r
80 > 1 files changed, 5 insertions(+), 3 deletions(-)
\r
82 > diff --git a/notmuch-new.c b/notmuch-new.c
\r
83 > index a569a54..c536873 100644
\r
84 > --- a/notmuch-new.c
\r
85 > +++ b/notmuch-new.c
\r
86 > @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
89 > talloc_free (next);
\r
95 > + if (fs_entries){
\r
96 > + for (i = 0; i < num_fs_entries; i++){
\r
97 > + free (fs_entries[i]);
\r
99 > free (fs_entries);
\r
102 > notmuch_filenames_destroy (db_subdirs);
\r
107 > _______________________________________________
\r
108 > notmuch mailing list
\r
109 > notmuch@notmuchmail.org
\r
110 > http://notmuchmail.org/mailman/listinfo/notmuch
\r