]> Cypherpunks repositories - gostls13.git/commit
runtime: avoid overflow in (*mheap).grow
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 6 May 2020 19:18:07 +0000 (19:18 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 7 May 2020 21:39:50 +0000 (21:39 +0000)
commit14ae846f54c105f4d48f1afa5aa5446e4b9e7cdc
treed36d6c108d9645d077a9a2d9ab5c77af40e4aafd
parentf9640b88c7e5f4df3350643f3ec6c30c30e8678d
runtime: avoid overflow in (*mheap).grow

Currently when checking if we can grow the heap into the current arena,
we do an addition which may overflow. This is particularly likely on
32-bit systems.

Avoid this situation by explicitly checking for overflow, and adding in
some comments about when overflow is possible, when it isn't, and why.

For #35954.

Change-Id: I2d4ecbb1ccbd43da55979cc721f0cd8d1757add2
Reviewed-on: https://go-review.googlesource.com/c/go/+/231337
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/runtime/mheap.go