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 EBA08431FAF
\r
6 for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 00:26:26 -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 6WJduB45Z3rC for <notmuch@notmuchmail.org>;
\r
16 Tue, 7 Feb 2012 00:26:26 -0800 (PST)
\r
17 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com
\r
18 [209.85.216.181]) (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 3168D431FAE
\r
21 for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 00:26:26 -0800 (PST)
\r
22 Received: by qcsd17 with SMTP id d17so4513675qcs.26
\r
23 for <notmuch@notmuchmail.org>; Tue, 07 Feb 2012 00:26:24 -0800 (PST)
\r
24 Received: by 10.229.134.210 with SMTP id k18mr8559725qct.136.1328603180092;
\r
25 Tue, 07 Feb 2012 00:26:20 -0800 (PST)
\r
26 Received: from localhost (nikula.org. [92.243.24.172])
\r
27 by mx.google.com with ESMTPS id j17sm19311897qaj.9.2012.02.07.00.26.18
\r
28 (version=SSLv3 cipher=OTHER); Tue, 07 Feb 2012 00:26:19 -0800 (PST)
\r
29 From: Jani Nikula <jani@nikula.org>
\r
30 To: Ethan Glasser-Camp <glasse@cs.rpi.edu>, notmuch@notmuchmail.org
\r
31 Subject: Re: [PATCH v2] Free the results of scandir()
\r
32 In-Reply-To: <1328597405-6437-1-git-send-email-glasse@cs.rpi.edu>
\r
33 References: <1328597405-6437-1-git-send-email-glasse@cs.rpi.edu>
\r
34 User-Agent: Notmuch/0.11.1+158~g413777a (http://notmuchmail.org) Emacs/23.1.1
\r
36 Date: Tue, 07 Feb 2012 08:26:16 +0000
\r
37 Message-ID: <87sjinqcbb.fsf@nikula.org>
\r
39 Content-Type: text/plain; charset=us-ascii
\r
40 Cc: Petter Reinholdtsen <pere@hungry.com>,
\r
41 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: Tue, 07 Feb 2012 08:26:27 -0000
\r
56 On Tue, 7 Feb 2012 01:50:05 -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
67 Looks good. Thanks, Ethan.
\r
69 David, I'm not sure if this is worth a bugfix release on its own, but
\r
70 definitely worth including if something else comes up.
\r
72 id:"2flfwhht87d.fsf@diskless.uio.no" is a report about potential memory
\r
73 leak in notmuch new from a few months back. CC Petter, the reporter.
\r
77 > Fixes the other use of scandir in count_files. Thanks, Jani.
\r
79 > notmuch-new.c | 16 ++++++++++------
\r
80 > 1 files changed, 10 insertions(+), 6 deletions(-)
\r
82 > diff --git a/notmuch-new.c b/notmuch-new.c
\r
83 > index a569a54..e62560b 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
104 > @@ -704,10 +706,12 @@ count_files (const char *path, int *count)
\r
110 > - if (fs_entries)
\r
111 > + if (fs_entries){
\r
112 > + for (i = 0; i < num_fs_entries; i++){
\r
113 > + free (fs_entries[i]);
\r
115 > free (fs_entries);
\r
123 > _______________________________________________
\r
124 > notmuch mailing list
\r
125 > notmuch@notmuchmail.org
\r
126 > http://notmuchmail.org/mailman/listinfo/notmuch
\r