From 9d8fbfea055ee525c48659210896f8fc0632696b Mon Sep 17 00:00:00 2001 From: wingrez Date: Tue, 8 Jul 2025 23:09:21 +0800 Subject: [PATCH] runtime: move needzero check behind doubleCheckMalloc --- src/runtime/malloc.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)