From patchwork Tue May 7 06:43:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 242036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 4EFF12C0142 for ; Tue, 7 May 2013 16:43:58 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UZbcf-0007JW-Dc; Tue, 07 May 2013 06:43:37 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UZbcZ-0007I6-7g for fwts-devel@lists.ubuntu.com; Tue, 07 May 2013 06:43:31 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1UZbcZ-0004G4-4H for fwts-devel@lists.ubuntu.com; Tue, 07 May 2013 06:43:31 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] lib: fwts_args: free long_options on error Date: Tue, 7 May 2013 07:43:30 +0100 Message-Id: <1367909010-31553-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.1.2 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Coverity CID#997347: Resource leak We need to free long_options on the error path too. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Keng-Yu Lin --- src/lib/src/fwts_args.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/src/fwts_args.c b/src/lib/src/fwts_args.c index 05c4c00..483fa30 100644 --- a/src/lib/src/fwts_args.c +++ b/src/lib/src/fwts_args.c @@ -132,6 +132,7 @@ int fwts_args_parse(fwts_framework *fw, const int argc, char * const argv[]) short_options = realloc(short_options, short_options_len + len + 1); if (short_options == NULL) { + free(long_options); fwts_log_error(fw, "Out of memory " "allocating options."); @@ -142,6 +143,7 @@ int fwts_args_parse(fwts_framework *fw, const int argc, char * const argv[]) } else { short_options = calloc(1, len + 1); if (short_options == NULL) { + free(long_options); fwts_log_error(fw, "Out of memory " "allocating options.");