]> Cypherpunks repositories - gostls13.git/commitdiff
gc: do not crash on bad [...]T
authorRuss Cox <rsc@golang.org>
Thu, 1 Jul 2010 03:34:31 +0000 (20:34 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 1 Jul 2010 03:34:31 +0000 (20:34 -0700)
Fixes #879.

R=ken2
CC=golang-dev
https://golang.org/cl/1678048

src/cmd/gc/align.c

index 0d4fa991f3f8a37536893017b5371b7d050e4a34..1b9112d69a3f0be36d556f34dc6dfc6c06b18f6b 100644 (file)
@@ -225,6 +225,8 @@ dowidth(Type *t)
                        uint64 cap;
 
                        dowidth(t->type);
+                       if(t->type->width == 0)
+                               fatal("no width for type %T", t->type);
                        if(tptr == TPTR32)
                                cap = ((uint32)-1) / t->type->width;
                        else
@@ -275,6 +277,9 @@ dowidth(Type *t)
                break;
        }
 
+       // catch all for error cases; avoid divide by zero later
+       if(w == 0)
+               w = maxround;
        t->width = w;
        lineno = lno;