From b72521ee505f5f71002d6e9114d32075c2a3b847 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 22 Aug 2022 17:37:07 -0700 Subject: [PATCH] debug/macho: don't use narch for seenArches map size If narch is very large we would allocate a lot of memory for seenArches. In practice we aren't going to see many different architectures so don't bother to specify a size for the seenArches map. No debug/macho test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. For #47653 For #52523 Change-Id: I5a3b0e3aa6172ddffd6f44d9ae513c39a00d8764 Reviewed-on: https://go-review.googlesource.com/c/go/+/425114 TryBot-Result: Gopher Robot Reviewed-by: David Chase Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Joseph Tsai --- src/debug/macho/fat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/macho/fat.go b/src/debug/macho/fat.go index 775beaf12c..7dc03fa79a 100644 --- a/src/debug/macho/fat.go +++ b/src/debug/macho/fat.go @@ -80,7 +80,7 @@ func NewFatFile(r io.ReaderAt) (*FatFile, error) { // Combine the Cpu and SubCpu (both uint32) into a uint64 to make sure // there are not duplicate architectures. - seenArches := make(map[uint64]bool, narch) + seenArches := make(map[uint64]bool) // Make sure that all images are for the same MH_ type. var machoType Type -- 2.50.0