From patchwork Thu Jun 8 21:02:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 20852 Received: (qmail 117355 invoked by alias); 8 Jun 2017 21:02:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 117341 invoked by uid 89); 8 Jun 2017 21:02:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1436 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Jun 2017 21:02:30 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D393C05091D; Thu, 8 Jun 2017 21:02:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D393C05091D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D393C05091D Received: from psique.yyz.redhat.com (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00E5218134; Thu, 8 Jun 2017 21:02:30 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Yao Qi , Sergio Durigan Junior Subject: [commit/obvious] Fix possible bug when no args have been provided to the executable Date: Thu, 8 Jun 2017 17:02:29 -0400 Message-Id: <20170608210229.30780-1-sergiodj@redhat.com> In-Reply-To: <86tw3qa0vd.fsf@gmail.com> References: <86tw3qa0vd.fsf@gmail.com> X-IsSubscribed: yes Hi, This bug is related to: On stringify_argv, we have to check if args[0] is not NULL before stringifying anything, otherwise we might do the wrong thing when trimming the "ret" string in the end. args[0] will be NULL when no arguments are passed to the inferior that will be started. Checked in as obvious. gdb/ChangeLog: 2017-06-08 Sergio Durigan Junior * common/common-utils.c (stringify_argv): Check for "arg[0] != NULL". --- gdb/ChangeLog | 5 +++++ gdb/common/common-utils.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 993fabe..5ebc7f8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-06-08 Sergio Durigan Junior + + * common/common-utils.c (stringify_argv): Check for "arg[0] != + NULL". + 2017-06-08 Alan Hayward * mn10300-tdep.c (MN10300_MAX_REGISTER_SIZE): Add. diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c index 793ab3b..e75a1b9 100644 --- a/gdb/common/common-utils.c +++ b/gdb/common/common-utils.c @@ -337,7 +337,7 @@ stringify_argv (const std::vector &args) { std::string ret; - if (!args.empty ()) + if (!args.empty () && args[0] != NULL) { for (auto s : args) if (s != NULL)