]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix compilation crash with several blank labels
authornimelehin <nimelehin@gmail.com>
Mon, 11 Apr 2022 16:54:30 +0000 (19:54 +0300)
committerGopher Robot <gobot@golang.org>
Tue, 12 Apr 2022 00:32:31 +0000 (00:32 +0000)
Fixes #52278

Change-Id: Ibf67c7b019feec277d316e04d93b458efea133fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/399574
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/cmd/compile/internal/escape/escape.go
src/cmd/compile/internal/escape/stmt.go
test/fixedbugs/issue52278.go [new file with mode: 0644]

index 4713ecddcaea52aa814ddc96c5a79930f04e324b..4408a531eca5fa2f65d6b9cd5b5dd8a57dffed17 100644 (file)
@@ -210,6 +210,9 @@ func (b *batch) walkFunc(fn *ir.Func) {
                switch n.Op() {
                case ir.OLABEL:
                        n := n.(*ir.LabelStmt)
+                       if n.Label.IsBlank() {
+                               break
+                       }
                        if e.labels == nil {
                                e.labels = make(map[*types.Sym]labelState)
                        }
index 0afb5d64ef681433aa031e2334da33c71d3e3991..4e8dd904ffb59bbf5ea7e8f7ff9eec96ee1d9e22 100644 (file)
@@ -50,6 +50,9 @@ func (e *escape) stmt(n ir.Node) {
 
        case ir.OLABEL:
                n := n.(*ir.LabelStmt)
+               if n.Label.IsBlank() {
+                       break
+               }
                switch e.labels[n.Label] {
                case nonlooping:
                        if base.Flag.LowerM > 2 {
diff --git a/test/fixedbugs/issue52278.go b/test/fixedbugs/issue52278.go
new file mode 100644 (file)
index 0000000..56169e6
--- /dev/null
@@ -0,0 +1,12 @@
+// compile
+
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main() {
+_:
+_:
+}