From f5cd92a82600067835c05c7e82726161a150a50b Mon Sep 17 00:00:00 2001 From: Ty Smith Date: Thu, 19 Nov 2015 11:04:34 -0600 Subject: [PATCH] cmELF: Avoid divide by zero if there are no dynamic section entries --- Source/cmELF.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index d062987b1..37dd328db 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -567,8 +567,14 @@ bool cmELFInternalImpl::LoadDynamicSection() return true; } - // Allocate the dynamic section entries. + // If there are no entries we are done. ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex]; + if(sec.sh_entsize == 0) + { + return false; + } + + // Allocate the dynamic section entries. int n = static_cast(sec.sh_size / sec.sh_entsize); this->DynamicSectionEntries.resize(n);