From patchwork Mon Nov 3 16:22:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 5218091 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3C2BEC11AC for ; Mon, 3 Nov 2014 16:25:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7598820125 for ; Mon, 3 Nov 2014 16:25:16 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 767392014A for ; Mon, 3 Nov 2014 16:25:15 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 053A326050B; Mon, 3 Nov 2014 17:25:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D8A35260519; Mon, 3 Nov 2014 17:25:04 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 697A6260525; Mon, 3 Nov 2014 17:22:37 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 6E41726052A for ; Mon, 3 Nov 2014 17:22:29 +0100 (CET) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 18086AC0F for ; Mon, 3 Nov 2014 16:22:29 +0000 (UTC) From: Andreas Schwab To: alsa-devel@alsa-project.org X-Yow: I'll clean your ROOM!! I know some GOOD stories, too!! All about ROAD Island's, HUSH Puppies, and how LUKE finds GOLD on his LAND!! Date: Mon, 03 Nov 2014 17:22:28 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 03 Nov 2014 17:25:04 +0100 Subject: [alsa-devel] [PATCH] snd_user_file: fix memory leak X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Call wordfree if and only if wordfree returns zero or WRDE_NOSPACE Signed-off-by: Andreas Schwab --- src/userfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/userfile.c b/src/userfile.c index 3a73836..72779da 100644 --- a/src/userfile.c +++ b/src/userfile.c @@ -44,19 +44,20 @@ int snd_user_file(const char *file, char **result) err = wordexp(file, &we, WRDE_NOCMD); switch (err) { case WRDE_NOSPACE: + wordfree(&we); return -ENOMEM; case 0: if (we.we_wordc == 1) break; + wordfree(&we); /* fall thru */ default: - wordfree(&we); return -EINVAL; } *result = strdup(we.we_wordv[0]); + wordfree(&we); if (*result == NULL) return -ENOMEM; - wordfree(&we); return 0; }