From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 89659431FAF for ; Mon, 6 Feb 2012 14:03:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.54 X-Spam-Level: X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SORBS_WEB=0.614] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yzxeCoz-IYrM for ; Mon, 6 Feb 2012 14:03:34 -0800 (PST) Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu [128.113.126.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 6301A431FAE for ; Mon, 6 Feb 2012 14:03:34 -0800 (PST) X-Hash: S|87554d9768bab8a4ccc4379bb721ab9fd9e7450b|8e3fb853444f45e635c0d8a16b0e28ee X-Countries: Cameroon, United States X-SMTP-From: accepted [195.24.209.22] [195.24.209.22] (localhost) {Cameroon} DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from :to:cc:subject:date:message-id; s=default; i=glasse@cs.rpi.edu; t=1328565812; x=1329170612; l=1091; bh=uSo3tBW0aK3WJQQVKhpr4qpF VBY=; b=Ejx77AwPL7XW4mkdIl6aU+Ro8yziNpjbIe1DExZC9biSASWXqgZFjgAI WTOhHnqdw65rxkAXdiWMdpu+uW/4aJaBdW+Fw1bsxwUbN917/cLBvsqtGyDOES2M 9iIOrjq1bSMZdbtU1rclfJZW9GUTDsmELC3hA1lKjWDnON0pz1E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc :subject:date:message-id; q=dns; s=default; b=XRgRNfMyh1see/P6b+ jtPi3vcxVfvF6dE/BysPB0fGyLA+XOF66A0oTdg82H0YtdWJhC1tQmS0eDDfsJxr 1rpj3Ije/+80PLF1Vis0RuRQ7KjpEEk6c1EtjjeofZd2JTPf27MCkdc2T8J8tIr/ XEJvfcrQyBQTmgUL5WxHhzzXc= X-Spam-Info: -2.7; ALL_TRUSTED,AWL,BAYES_00 X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit 15) Authentication-Results: cliffclavin.cs.rpi.edu; DKIM=neutral (none) header.from=glasse@cs.rpi.edu; SPF=neutral (mfrom; Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu X-Auth-Passed: cliffclavin.cs.rpi.edu:q16M38mA069463 Auth:glasse X-Virus-Scanned-By: cliffclavin.cs.rpi.edu Received: from localhost ([195.24.209.22]) (authenticated bits=0) by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q16M38mA069463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 6 Feb 2012 17:03:24 -0500 (EST) (envelope-from glasse@cs.rpi.edu) From: Ethan Glasser-Camp To: notmuch@notmuchmail.org Subject: [PATCH] Free the results of scandir() Date: Mon, 6 Feb 2012 17:02:49 -0500 Message-Id: <1328565769-29414-1-git-send-email-glasse@cs.rpi.edu> X-Mailer: git-send-email 1.7.5.4 X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25 Cc: Ethan Glasser-Camp X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2012 22:03:41 -0000 From: Ethan Glasser-Camp scandir() returns "strings allocated via malloc(3)" which are then "collected in array namelist which is allocated via malloc(3)". Currently we just free the array namelist. Instead, free all the entries of namelist, and then free namelist. entry only points to elements of namelist, so we don't free it separately. --- This should fix a minor memory leak in notmuch-new. Please confirm I'm reading the manpage correctly ;) notmuch-new.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index a569a54..c536873 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch, DONE: if (next) talloc_free (next); - if (entry) - free (entry); if (dir) closedir (dir); - if (fs_entries) + if (fs_entries){ + for (i = 0; i < num_fs_entries; i++){ + free (fs_entries[i]); + } free (fs_entries); + } if (db_subdirs) notmuch_filenames_destroy (db_subdirs); if (db_files) -- 1.7.5.4