[llvm-branch-commits] [llvm-branch] r104494 - /llvm/branches/Apple/whitney/include/llvm/MC/MCObjectWriter.h
Daniel Dunbar
daniel at zuster.org
Mon May 24 08:15:01 PDT 2010
Author: ddunbar
Date: Mon May 24 10:15:00 2010
New Revision: 104494
URL: http://llvm.org/viewvc/llvm-project?rev=104494&view=rev
Log:
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.
Modified:
llvm/branches/Apple/whitney/include/llvm/MC/MCObjectWriter.h
Modified: llvm/branches/Apple/whitney/include/llvm/MC/MCObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/include/llvm/MC/MCObjectWriter.h?rev=104494&r1=104493&r2=104494&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/include/llvm/MC/MCObjectWriter.h (original)
+++ llvm/branches/Apple/whitney/include/llvm/MC/MCObjectWriter.h Mon May 24 10:15:00 2010
@@ -152,6 +152,8 @@
}
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());
More information about the llvm-branch-commits
mailing list