From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76366 invoked by alias); 26 Nov 2017 09:05:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 76349 invoked by uid 89); 26 Nov 2017 09:05:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail.ud10.udmedia.de Received: from ud10.udmedia.de (HELO mail.ud10.udmedia.de) (194.117.254.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Nov 2017 09:05:24 +0000 Received: (qmail 18443 invoked from network); 26 Nov 2017 10:05:20 +0100 Received: from ip5b405f48.dynamic.kabel-deutschland.de (HELO x4) (ud10?360p3@91.64.95.72) by mail.ud10.udmedia.de with ESMTPSA (ECDHE-RSA-AES256-SHA encrypted, authenticated); 26 Nov 2017 10:05:20 +0100 Date: Sun, 26 Nov 2017 10:14:00 -0000 From: Markus Trippelsdorf To: Richard Biener Cc: Jason Merrill , gcc-patches List Subject: [PATCH] Fix UB in hash-map.h Message-ID: <20171126090520.GA367@x4> References: <20171125194217.GA367@x4> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171125194217.GA367@x4> X-SW-Source: 2017-11/txt/msg02248.txt.bz2 bootstrap-ubsan shows: gcc/hash-map.h:277:19: runtime error: member access within null pointer of type 'struct hash_map' Fix the issue by returning early. bootstrap-ubsan on X86_64 and ppc64le. Tested on ppc64le. OK for trunk? gcc/ * hash-map.h (gt_cleare_cache): Avoid UB. diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 6b8365a9d0a6..e5630338491a 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -274,6 +274,8 @@ template static inline void gt_cleare_cache (hash_map *h) { + if (!h) + return; gt_cleare_cache (&h->m_table); } -- Markus