From patchwork Sat Apr 19 02:35:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 621 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 3C94736007E for ; Fri, 18 Apr 2014 19:38:15 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id E687A4BEAA4D; Fri, 18 Apr 2014 19:38:14 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id BBEB54BEC26B for ; Fri, 18 Apr 2014 19:38:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=UL7XFb65K+QzoG41nXQ76Q0vnPf2t sn9duv13KBWNS1/XVecUcZ5NGBrGSKufvHTJJiPbrt8Ve3KGsOPKjE28ivUkSP06 QtLxHkGvJbfzm8XuBJEXJr/lzfyx4wtamt9+ZrGCIxr+JAgoOOBHPuV/Pmds3I8T anpsePs0OdRz78= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=/tk+XKD112SWf+4lpOC2M4WdId8=; b=Wpc 0zJNs+OctEcB8RVqMTaZkWgxXQgCybMyICgEuN7YcDcgygX1TvlxvkRQP0Z94yrx 7QzvcsV3oAVu+povSfXiMcZ7KI0ys4tjf9Qjy9xUUfWC1NZo/BxUtmjlIKS/vJza 3eO2Z0UsU0JbDpKPLg4pv4y5INT8I5SrXol0fm40= Received: (qmail 22050 invoked by alias); 19 Apr 2014 02:38:13 -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 22040 invoked by uid 89); 19 Apr 2014 02:38:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 Apr 2014 02:38:11 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WbLAN-00002x-Cg from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 18 Apr 2014 19:38:07 -0700 Received: from SVR-ORW-FEM-06.mgc.mentorg.com ([147.34.97.120]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 18 Apr 2014 19:38:06 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.2.247.3; Fri, 18 Apr 2014 19:38:06 -0700 From: Yao Qi To: Subject: [PUSHED PATCH] Add null pointer check in ctf_xfer_partial Date: Sat, 19 Apr 2014 10:35:05 +0800 Message-ID: <1397874905-31010-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in I find a gdb crash when gdb reads ctf trace. The crash is caused by passing NULL to strcmp. This patch is to add null pointer check, as what we did somewhere else in ctf.c. Patch is pushed in. gdb: 2014-04-19 Yao Qi * ctf.c (ctf_xfer_partial): Check 'name' is NULL before strcmp. --- gdb/ChangeLog | 4 ++++ gdb/ctf.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 21907fa..2d2b839 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2014-04-19 Yao Qi + + * ctf.c (ctf_xfer_partial): Check 'name' is NULL before strcmp. + 2014-04-18 Siva Chandra Reddy * valops.c (oload_method_static): Remove unnecessary argument diff --git a/gdb/ctf.c b/gdb/ctf.c index df9ca52..f21dcdf 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -1402,7 +1402,7 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, = bt_ctf_iter_read_event (ctf_iter); const char *name = bt_ctf_event_name (event); - if (strcmp (name, "frame") == 0) + if (name == NULL || strcmp (name, "frame") == 0) break; else if (strcmp (name, "memory") != 0) {