]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix map assignment with panicking right-hand side
authorKeith Randall <khr@google.com>
Mon, 4 Dec 2017 22:47:32 +0000 (14:47 -0800)
committerKeith Randall <khr@golang.org>
Tue, 5 Dec 2017 00:10:10 +0000 (00:10 +0000)
commitdd7cbf3a846c2cb125ac65173abaf6a8b9f903ff
tree8f40c24b842c5fdfd8951f20f95b8cc29b226e30
parent2ff2eab0d240ec4ccfbc05f17afa8d99c6fbed61
cmd/compile: fix map assignment with panicking right-hand side

Make sure that when we're assigning to a map, we evaluate the
right-hand side before we attempt to insert into the map.

We used to evaluate the left-hand side to a pointer-to-slot-in-bucket
(which as a side effect does len(m)++), then evaluate the right-hand side,
then do the assignment. That clearly isn't correct when the right-hand side
might panic.

Fixes #22881

Change-Id: I42a62870ff4bf480568c9bdbf0bb18958962bdf0
Reviewed-on: https://go-review.googlesource.com/81817
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/order.go
test/fixedbugs/issue22881.go [new file with mode: 0644]