From d16bbc5340a4d16f8b63b265f46d9a5946e8cc00 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Wed, 9 Mar 2022 20:24:20 -0800 Subject: [PATCH] [BOLT][NFC] Check errors from Obj.dynamicEntries Addresses fuzzer crash Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D121336 --- bolt/lib/Rewrite/RewriteInstance.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index 1c5d52b227e6..ea2cee1b01b0 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -5135,8 +5135,10 @@ Error RewriteInstance::readELFDynamic(ELFObjectFile *File) { "dynamic section sizes should match"); // Go through all dynamic entries to locate entries of interest. - typename ELFT::DynRange DynamicEntries = - cantFail(Obj.dynamicEntries(), "error accessing dynamic table"); + auto DynamicEntriesOrErr = Obj.dynamicEntries(); + if (!DynamicEntriesOrErr) + return DynamicEntriesOrErr.takeError(); + typename ELFT::DynRange DynamicEntries = DynamicEntriesOrErr.get(); for (const Elf_Dyn &Dyn : DynamicEntries) { switch (Dyn.d_tag) {