1
0
mirror of https://github.com/golang/go synced 2024-11-19 05:24:42 -07:00

cmd/gc: fix undefined behavior

UndefinedBehaviorSanitizer claims it is UB in C:
src/cmd/gc/racewalk.c:422:37: runtime error: member access within null pointer of type 'Node' (aka 'struct Node')
src/cmd/gc/racewalk.c:423:37: runtime error: member access within null pointer of type 'Node' (aka 'struct Node')

LGTM=rsc
R=dave, rsc
CC=golang-codereviews
https://golang.org/cl/125570043
This commit is contained in:
Dmitriy Vyukov 2014-08-21 12:34:26 +04:00
parent 99e9bac8c4
commit 1f5800673b

View File

@ -419,8 +419,10 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
ret:
if(n->op != OBLOCK) // OBLOCK is handled above in a special way.
racewalklist(n->list, init);
racewalknode(&n->ntest, &n->ntest->ninit, 0, 0);
racewalknode(&n->nincr, &n->nincr->ninit, 0, 0);
if(n->ntest != N)
racewalknode(&n->ntest, &n->ntest->ninit, 0, 0);
if(n->nincr != N)
racewalknode(&n->nincr, &n->nincr->ninit, 0, 0);
racewalklist(n->nbody, nil);
racewalklist(n->nelse, nil);
racewalklist(n->rlist, nil);