diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index bc7dab9d20e6b9..8c8be1e55c28ff 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -1059,8 +1059,10 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { x, elemsize = mallocgcSmallNoscan(size, typ, needzero) } } else { - if !needzero { - throw("objects with pointers must be zeroed") + if doubleCheckMalloc { + if !needzero { + throw("objects with pointers must be zeroed") + } } if heapBitsInSpan(size) { x, elemsize = mallocgcSmallScanNoHeader(size, typ)