浏览代码

Merge topic 'avoid-divide-by-zero'

f5cd92a8 cmELF: Avoid divide by zero if there are no dynamic section entries
Brad King 10 年之前
父节点
当前提交
d1f4b6b501
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      Source/cmELF.cxx

+ 7 - 1
Source/cmELF.cxx

@@ -567,8 +567,14 @@ bool cmELFInternalImpl<Types>::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<int>(sec.sh_size / sec.sh_entsize);
   this->DynamicSectionEntries.resize(n);