summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Jeffords <blunted2night@gmail.com>2010-05-21 18:23:56 +0000
committerNathan Jeffords <blunted2night@gmail.com>2010-05-21 18:23:56 +0000
commitea91abddfe8b9681d92b75721991acc3f9746256 (patch)
tree9c7ca97e98d737c9f6bf046b674f3395a9cd189f
parent0735ecfe17387acc0e5dc2914b01de08bb031ac5 (diff)
downloadbcm5719-llvm-ea91abddfe8b9681d92b75721991acc3f9746256.tar.gz
bcm5719-llvm-ea91abddfe8b9681d92b75721991acc3f9746256.zip
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. llvm-svn: 104334
-rw-r--r--llvm/include/llvm/MC/MCObjectWriter.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/include/llvm/MC/MCObjectWriter.h b/llvm/include/llvm/MC/MCObjectWriter.h
index 5d3493ca25c..70535206aac 100644
--- a/llvm/include/llvm/MC/MCObjectWriter.h
+++ b/llvm/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());
OpenPOWER on IntegriCloud