Commit c1cbe5b5 authored by Austin Clements's avatar Austin Clements

runtime: check for spanBytesAlloc underflow

Change-Id: I5e6739ff0c6c561195ed9891fb90f933b81e7750
Reviewed-on: https://go-review.googlesource.com/17746
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 6383fb61
......@@ -393,7 +393,9 @@ func reimburseSweepCredit(unusableBytes uintptr) {
// Nobody cares about the credit. Avoid the atomic.
return
}
atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))
if int64(atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))) < 0 {
throw("spanBytesAlloc underflow")
}
}
func dumpFreeList(s *mspan) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment