1
0
mirror of https://github.com/golang/go synced 2024-11-22 04:24:39 -07:00

gc: do not crash on bad [...]T

Fixes #879.

R=ken2
CC=golang-dev
https://golang.org/cl/1678048
This commit is contained in:
Russ Cox 2010-06-30 20:34:31 -07:00
parent 040f081842
commit ed39c764b8

View File

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