From patchwork Tue Apr 10 14:17:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 151580 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 98BACB6FDB for ; Wed, 11 Apr 2012 00:18:02 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SHbtR-00036d-Dz for incoming@patchwork.ozlabs.org; Tue, 10 Apr 2012 14:18:01 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SHbtP-00036V-KN for fwts-devel@lists.ubuntu.com; Tue, 10 Apr 2012 14:17:59 +0000 Received: from cpc19-craw6-2-0-cust5.croy.cable.virginmedia.com ([77.102.228.6] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SHbtP-0004BC-Hp for fwts-devel@lists.ubuntu.com; Tue, 10 Apr 2012 14:17:59 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] lib: fwts_args: only handle non-zero length short_names Date: Tue, 10 Apr 2012 15:17:58 +0100 Message-Id: <1334067478-812-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.9.1 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Keng-Yu Lin --- src/lib/src/fwts_args.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/src/fwts_args.c b/src/lib/src/fwts_args.c index 90f3d70..b5ef3e0 100644 --- a/src/lib/src/fwts_args.c +++ b/src/lib/src/fwts_args.c @@ -116,14 +116,14 @@ int fwts_args_parse(fwts_framework *fw, int argc, char * const argv[]) for (i=0; inum_options; i++, n++) { char *short_name = options_table->options[i].short_name; + size_t len; long_options[n].name = options_table->options[i].long_name; long_options[n].has_arg = options_table->options[i].has_arg; long_options[n].flag = 0; long_options[n].val = 0; - if (short_name != NULL) { - int len = strlen(short_name); + if (short_name && (len = strlen(short_name)) > 0) { if (short_options) { short_options = realloc(short_options, strlen(short_options) + len + 1);