From d7e65757ed8f2dfe17b71cf169a3c83a155d1c2b Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 7 Jul 2021 11:44:22 -0400 Subject: [PATCH] [lld/mac] Tweak reserve() argument in unwind code addEntriesForFunctionsWithoutUnwindInfo() can add entries to cuVector, so cuCount can be stale. Use cuVector.size() instead. No behavior change. --- lld/MachO/UnwindInfoSection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp index 3bc1ec3..4864a24 100644 --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -379,7 +379,7 @@ template void UnwindInfoSectionImpl::finalize() { // Rather than sort & fold the 32-byte entries directly, we create a // vector of pointers to entries and sort & fold that instead. - cuPtrVector.reserve(cuCount); + cuPtrVector.reserve(cuVector.size()); for (CompactUnwindEntry &cuEntry : cuVector) cuPtrVector.emplace_back(&cuEntry); llvm::sort(cuPtrVector, [](const CompactUnwindEntry *a, -- 2.7.4