From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119912 invoked by alias); 2 Oct 2018 04:44:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 119795 invoked by uid 89); 2 Oct 2018 04:44:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.102) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Oct 2018 04:44:25 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway32.websitewelcome.com (Postfix) with ESMTP id E0B5439F82 for ; Mon, 1 Oct 2018 23:44:22 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 7CXmgpG4d79N37CXmgxBU4; Mon, 01 Oct 2018 23:44:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pLpaAIfsahns97AMJLJxy6b0vKzcuwoITCb3Moi0qU8=; b=VY0LNpRATiz20jsghm33WYl8Q1 4MRdG9N2yTYZuRti2jLS0wEkDVpCfjo5jCt2yt7eF5acsJsOj7DIqkmT97NpX3KwtLZ12+10806bN 0FjM9y2lCDeUih3SCHQ1BZy/U; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:32984 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g7CXm-003mHT-MC; Mon, 01 Oct 2018 23:44:22 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 01/10] Do not pass NULL to memcpy Date: Tue, 02 Oct 2018 04:44:00 -0000 Message-Id: <20181002044420.17628-2-tom@tromey.com> In-Reply-To: <20181002044420.17628-1-tom@tromey.com> References: <20181002044420.17628-1-tom@tromey.com> X-SW-Source: 2018-10/txt/msg00042.txt.bz2 -fsanitize=undefined pointed out a spot that passes NULL to memcpy, which is undefined behavior according to the C standard. gdb/ChangeLog 2018-10-01 Tom Tromey * namespace.c (add_using_directive): Don't pass NULL to memcpy. --- gdb/ChangeLog | 4 ++++ gdb/namespace.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/namespace.c b/gdb/namespace.c index be998d9d49..85c0c4b14d 100644 --- a/gdb/namespace.c +++ b/gdb/namespace.c @@ -111,8 +111,9 @@ add_using_directive (struct using_direct **using_directives, else newobj->declaration = declaration; - memcpy (newobj->excludes, excludes.data (), - excludes.size () * sizeof (*newobj->excludes)); + if (!excludes.empty ()) + memcpy (newobj->excludes, excludes.data (), + excludes.size () * sizeof (*newobj->excludes)); newobj->excludes[excludes.size ()] = NULL; newobj->next = *using_directives; -- 2.17.1