gc: reject large channel values at compile time

Fixes #144.

R=ken2
CC=agl1
https://golang.org/cl/156102
This commit is contained in:
Russ Cox 2009-11-19 18:20:06 -08:00
parent a6e1ad2733
commit d116a32727
2 changed files with 13 additions and 0 deletions

View File

@ -186,6 +186,18 @@ dowidth(Type *t)
case TCHAN: // implemented as pointer
w = widthptr;
checkwidth(t->type);
// make fake type to check later to
// trigger channel argument check.
t1 = typ(TCHANARGS);
t1->type = t;
checkwidth(t1);
break;
case TCHANARGS:
t1 = t->type;
dowidth(t->type); // just in case
if(t1->type->width >= (1<<16))
yyerror("channel element type too large (>64kB)");
break;
case TMAP: // implemented as pointer
w = widthptr;

View File

@ -441,6 +441,7 @@ enum
// pseudo-type for frame layout
TFUNCARGS,
TCHANARGS,
NTYPE,
};