From patchwork Tue Dec 21 22:56:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 76339 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0FCB7B6F07 for ; Wed, 22 Dec 2010 09:57:34 +1100 (EST) Received: (qmail 26946 invoked by alias); 21 Dec 2010 22:57:31 -0000 Received: (qmail 26936 invoked by uid 22791); 21 Dec 2010 22:57:30 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Dec 2010 22:57:25 +0000 Received: from hpaq7.eem.corp.google.com (hpaq7.eem.corp.google.com [172.25.149.7]) by smtp-out.google.com with ESMTP id oBLMvNGL018140 for ; Tue, 21 Dec 2010 14:57:23 -0800 Received: from pvh11 (pvh11.prod.google.com [10.241.210.203]) by hpaq7.eem.corp.google.com with ESMTP id oBLMvIlY004684 for ; Tue, 21 Dec 2010 14:57:22 -0800 Received: by pvh11 with SMTP id 11so1385108pvh.4 for ; Tue, 21 Dec 2010 14:57:21 -0800 (PST) Received: by 10.142.213.10 with SMTP id l10mr4967270wfg.199.1292972241458; Tue, 21 Dec 2010 14:57:21 -0800 (PST) Received: from coign.google.com (dhcp-172-22-122-207.mtv.corp.google.com [172.22.122.207]) by mx.google.com with ESMTPS id p8sm8188811wff.4.2010.12.21.14.56.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Dec 2010 14:57:11 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't crash when copying function without closure Date: Tue, 21 Dec 2010 14:56:42 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org A bug in the Go frontend caused it to crash when copying a function expression if the function had no closure. I'm not sure this ever happens for valid code, but it can happen for invalid code. This patch fixes it in the obvious way. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 4e845d05aafc go/expressions.h --- a/go/expressions.h Tue Dec 21 14:29:32 2010 -0800 +++ b/go/expressions.h Tue Dec 21 14:49:03 2010 -0800 @@ -1346,7 +1346,9 @@ do_copy() { return Expression::make_func_reference(this->function_, - this->closure_->copy(), + (this->closure_ == NULL + ? NULL + : this->closure_->copy()), this->location()); }