diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp index 3bc1ec3445ff..4864a248d6b1 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,