From patchwork Thu Feb 27 18:00:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 38340 Received: (qmail 110520 invoked by alias); 27 Feb 2020 18:00:51 -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 110423 invoked by uid 89); 27 Feb 2020 18:00:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Feb 2020 18:00:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582826436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=OzzC//jUeXWUA2HgUVsu0MstP+lActTB+GzWf/ja7Xc=; b=NExD9e40uqOX5XLyT5Vh+WFvBAOPIcxDLRtt+WcCHTKlqEaSP9+i6QDmsG0p3scBnXCk5Y 77S1aaIbQnBho44QFbw4zwInF5CzpABCsfX96KgVSozOy6oW8MbUhiJXtSup/GUm+UntAR xpk7tr6WpbadB9P68BpQebqqVLvEc20= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-vQR3qkJVNy21xiXkchLgHw-1; Thu, 27 Feb 2020 13:00:33 -0500 Received: by mail-vk1-f200.google.com with SMTP id s126so118062vkb.3 for ; Thu, 27 Feb 2020 10:00:33 -0800 (PST) MIME-Version: 1.0 From: Aaron Merey Date: Thu, 27 Feb 2020 13:00:22 -0500 Message-ID: Subject: [PATCH] gdb: Check for nullptr when computing srcpath To: gdb-patches@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From e3eb4852487b941a9efb4bbcc8b6fb5f522b8298 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Thu, 27 Feb 2020 12:52:05 -0500 Subject: [PATCH] gdb: Check for nullptr when computing srcpath gdb/ChangeLog: 2020-02-27 Aaron Merey * source.c (open_source_file): Check for nullptr when computing srcpath. --- gdb/ChangeLog | 4 ++++ gdb/source.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4376161673..371ef91421 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2020-02-27 Aaron Merey + * source.c (open_source_file): Check for nullptr when computing + srcpath. + 2020-02-27 Andrew Burgess * gdbtypes.c (create_array_type_with_stride): Use std::abs not diff --git a/gdb/source.c b/gdb/source.c index 051caf5c57..29eeb5341b 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1160,7 +1160,7 @@ open_source_file (struct symtab *s) std::string srcpath; if (IS_ABSOLUTE_PATH (s->filename)) srcpath = s->filename; - else + else if (SYMTAB_DIRNAME (s) != nullptr) { srcpath = SYMTAB_DIRNAME (s); srcpath += SLASH_STRING; @@ -1170,7 +1170,7 @@ open_source_file (struct symtab *s) const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd); /* Query debuginfod for the source file. */ - if (build_id != nullptr) + if (build_id != nullptr && srcpath.size () > 0) fd = debuginfod_source_query (build_id->data, build_id->size, srcpath.c_str (), -- 2.24.1