diff --git a/llvm/lib/DWP/DWP.cpp b/llvm/lib/DWP/DWP.cpp --- a/llvm/lib/DWP/DWP.cpp +++ b/llvm/lib/DWP/DWP.cpp @@ -18,6 +18,7 @@ #include "llvm/Object/Decompressor.h" #include "llvm/Object/ELFObjectFile.h" #include "llvm/Support/MemoryBuffer.h" +#include using namespace llvm; using namespace llvm::object; @@ -679,6 +680,9 @@ continue; } Out.emitBytes(Info.substr(UnitOffset - C.Length, C.Length)); + if (std::numeric_limits::max() - InfoSectionOffset < C.Length) + return make_error("Debug Info offset greater then 4GB."); + InfoSectionOffset += C.Length; } }