From: Nathan Jeffords Date: Fri, 21 May 2010 18:23:56 +0000 (+0000) Subject: added an assertion to MCObjectWriter::WriteBytes to catch misuse of the ZeroFillSize... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0783fb7e6d2f03cbb398dc0f083c96ba8af9ab21;p=oota-llvm.git added an assertion to MCObjectWriter::WriteBytes to catch misuse of the ZeroFillSize parameter If the size of the string is greater than the zero fill size, the function will attempt to write a very large string of zeros to the object file (~4GB on 32 bit platforms). This assertion will catch the scenario and crash the program before the write occurs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104334 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MC/MCObjectWriter.h b/include/llvm/MC/MCObjectWriter.h index 5d3493ca25c..70535206aac 100644 --- a/include/llvm/MC/MCObjectWriter.h +++ b/include/llvm/MC/MCObjectWriter.h @@ -152,6 +152,8 @@ public: } void WriteBytes(StringRef Str, unsigned ZeroFillSize = 0) { + assert((ZeroFillSize == 0 || Str.size () <= ZeroFillSize) && + "data size greater than fill size, unexpected large write will occur"); OS << Str; if (ZeroFillSize) WriteZeros(ZeroFillSize - Str.size());