diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index a43eca6f9769..a9a8107a7538 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -718,9 +718,11 @@ COFFObjectFile::COFFObjectFile(MemoryBufferRef Object, std::error_code &EC) } if ((EC = getObject(DataDirectory, Data, DataDirAddr, DataDirSize))) return; - CurPtr += COFFHeader->SizeOfOptionalHeader; } + if (COFFHeader) + CurPtr += COFFHeader->SizeOfOptionalHeader; + if ((EC = getObject(SectionTable, Data, base() + CurPtr, (uint64_t)getNumberOfSections() * sizeof(coff_section)))) return;