From patchwork Mon Aug 24 09:30:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1350167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BZn1L6yQLz9sPB; Mon, 24 Aug 2020 19:31:02 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1kA8od-0004os-Gz; Mon, 24 Aug 2020 09:30:59 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kA8oc-0004om-46 for fwts-devel@lists.ubuntu.com; Mon, 24 Aug 2020 09:30:58 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kA8ob-0007fS-SZ; Mon, 24 Aug 2020 09:30:57 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] lib: fwts_log_json: fix memory leak Date: Mon, 24 Aug 2020 10:30:57 +0100 Message-Id: <20200824093057.63672-1-colin.king@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King The string str is not being free'd after use, leading to a memory leak. Free it. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_log_json.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c index 1a917e63..7bb5110a 100644 --- a/src/lib/src/fwts_log_json.c +++ b/src/lib/src/fwts_log_json.c @@ -211,7 +211,7 @@ static void fwts_log_open_json(fwts_log_file *log_file) static void fwts_log_close_json(fwts_log_file *log_file) { - const char *str; + char *str; fwts_log_section_end_json(log_file); @@ -233,6 +233,7 @@ static void fwts_log_close_json(fwts_log_file *log_file) log_file->line_number++; } json_object_put(json_stack[0].obj); + free(str); } fwts_log_ops fwts_log_json_ops = {