From: Anthony Martin Date: Thu, 23 Feb 2012 19:28:16 +0000 (-0500) Subject: cc: fix an out of bounds array access X-Git-Tag: weekly.2012-03-04~194 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=436f297d1e8cb941d859a00467395a8c541035e6;p=gostls13.git cc: fix an out of bounds array access Alternatively, we could expand the ewidth array in [568]c/txt.c to have NALLTYPES elements and give all types above NTYPE a width of -1. I don't think it's worth it since TDOT and TOLD are the only two type values above NTYPE that are passed to typ: $ /tmp/cctypes cc/dcl.c:683: t->down = typ(TOLD, T); cc/dcl.c:919: return typ(TDOT, T); $ Fixes #3063. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5694047 --- diff --git a/src/cmd/cc/sub.c b/src/cmd/cc/sub.c index e5992e213b..98e9f5a4b4 100644 --- a/src/cmd/cc/sub.c +++ b/src/cmd/cc/sub.c @@ -156,7 +156,10 @@ typ(int et, Type *d) t->link = d; t->down = T; t->sym = S; - t->width = ewidth[et]; + if(et < NTYPE) + t->width = ewidth[et]; + else + t->width = -1; // for TDOT or TOLD in prototype t->offset = 0; t->shift = 0; t->nbits = 0;