summaryrefslogtreecommitdiff
path: root/src/cmd/gc/racewalk.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-08-21 12:34:26 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-08-21 12:34:26 +0400
commit0d7d5cad8266a4bf2e69b22a1aaf5f958c4e4a47 (patch)
tree94458b134d4c77d3760832c0fe8404a897ca39fe /src/cmd/gc/racewalk.c
parentbca1ef663d73896018dba0b24ce4c61b8db595de (diff)
downloadgo-0d7d5cad8266a4bf2e69b22a1aaf5f958c4e4a47.tar.gz
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://codereview.appspot.com/125570043
Diffstat (limited to 'src/cmd/gc/racewalk.c')
-rw-r--r--src/cmd/gc/racewalk.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cmd/gc/racewalk.c b/src/cmd/gc/racewalk.c
index 285bd78a2..27581702c 100644
--- a/src/cmd/gc/racewalk.c
+++ b/src/cmd/gc/racewalk.c
@@ -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);