From patchwork Thu Apr 10 14:07:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Batuzov X-Patchwork-Id: 338134 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D0DCB14019B for ; Fri, 11 Apr 2014 00:08:46 +1000 (EST) Received: from localhost ([::1]:52031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYFem-0006IY-SX for incoming@patchwork.ozlabs.org; Thu, 10 Apr 2014 10:08:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYFeQ-0006Bj-TP for qemu-devel@nongnu.org; Thu, 10 Apr 2014 10:08:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYFeK-0001OP-RA for qemu-devel@nongnu.org; Thu, 10 Apr 2014 10:08:22 -0400 Received: from smtp.ispras.ru ([83.149.199.79]:38844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYFeK-0001NF-JM; Thu, 10 Apr 2014 10:08:16 -0400 Received: from bulbul.intra.ispras.ru (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id 0E88B224AB; Thu, 10 Apr 2014 18:08:12 +0400 (MSK) From: Kirill Batuzov To: qemu-devel@nongnu.org Date: Thu, 10 Apr 2014 18:07:57 +0400 Message-Id: <1397138878-11770-1-git-send-email-batuzovk@ispras.ru> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.79 Cc: qemu-trivial@nongnu.org, Kirill Batuzov Subject: [Qemu-devel] [PATCH trivial] init_paths: fix minor memory leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Fields "name" (created with strdup in new_entry) and "pathname" (created with g_strdup_printf in new_entry) of pathelem struct should be freed before the whole struct is. Signed-off-by: Kirill Batuzov --- util/path.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/path.c b/util/path.c index 623219e..5c59d9f 100644 --- a/util/path.c +++ b/util/path.c @@ -160,7 +160,9 @@ void init_paths(const char *prefix) base = new_entry("", NULL, pref_buf); base = add_dir_maybe(base); if (base->num_entries == 0) { - free (base); + g_free(base->pathname); + free(base->name); + free(base); base = NULL; } else { set_parents(base, base);