]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/8g: don't crash if Prog->u.branch is nil
authorRob Pike <r@golang.org>
Thu, 30 Jan 2014 00:14:45 +0000 (16:14 -0800)
committerRob Pike <r@golang.org>
Thu, 30 Jan 2014 00:14:45 +0000 (16:14 -0800)
The code is copied from cmd/6g.
Empirically, all branch targets are nil in this code so
something is still wrong, but at least this stops 8g -S
from crashing.

Update #7178

LGTM=dave, iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/58400043

src/cmd/8g/list.c

index 96954d4bb3a87fe089e7b20a9c747eff4945c6a9..558d9c690d48b34640fc451b9cd487c22d838121 100644 (file)
@@ -107,7 +107,10 @@ Dconv(Fmt *fp)
                break;
 
        case D_BRANCH:
-               snprint(str, sizeof(str), "%d", a->u.branch->loc);
+               if(a->u.branch == nil)
+                       snprint(str, sizeof(str), "<nil>");
+               else
+                       snprint(str, sizeof(str), "%d", a->u.branch->loc);
                break;
 
        case D_EXTERN: