diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 02c096a859..74decd54c4 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -1064,7 +1064,11 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { if asanenabled { // Poison the space between the end of the requested size of x // and the end of the slot. Unpoison the requested allocation. - asanpoison(unsafe.Add(x, size-asanRZ), asanRZ+(elemsize-size)) + frag := elemsize - size + if typ != nil && typ.Pointers() && !heapBitsInSpan(elemsize) { + frag -= mallocHeaderSize + } + asanpoison(unsafe.Add(x, size-asanRZ), asanRZ+frag) asanunpoison(x, size-asanRZ) }