]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet/internal/cfg: don't crash on malformed goto statement
authorAlan Donovan <adonovan@google.com>
Wed, 22 Jun 2016 14:41:30 +0000 (10:41 -0400)
committerAlan Donovan <adonovan@google.com>
Wed, 22 Jun 2016 17:09:26 +0000 (17:09 +0000)
Change-Id: Ib285c02e240f02e9d5511bd448163ec1d4e75516
Reviewed-on: https://go-review.googlesource.com/24323
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/internal/cfg/builder.go
src/cmd/vet/internal/cfg/cfg_test.go

index 79c906bca0ba769d35e8ab3731afab88b0f9a00f..da1cc7e6384df279092fcfa16322771e66f2ec20 100644 (file)
@@ -98,7 +98,9 @@ start:
                        }
 
                case token.GOTO:
-                       block = b.labeledBlock(s.Label)._goto
+                       if s.Label != nil {
+                               block = b.labeledBlock(s.Label)._goto
+                       }
                }
                if block == nil {
                        block = b.newBlock("undefined.branch")
index 5d98f136bd5f4ae3ea2108d0a1b152f57445d211..2400fed6f4b2fc6c6012bbdc4f059ba29ff27870 100644 (file)
@@ -122,6 +122,12 @@ func f10(ch chan int) {
        }
        live()
 }
+
+func f11() {
+       goto; // mustn't crash
+       dead()
+}
+
 `
 
 func TestDeadCode(t *testing.T) {