1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Don't allow MCStreamer::EmitIntValue to output 0-byte integers.

It makes no sense and can hide bugs. In particular, it lead
to left shift by 64 bits, which is an undefined behavior,
properly reported by UBSan.

llvm-svn: 216134
This commit is contained in:
Alexey Samsonov 2014-08-20 22:46:38 +00:00
parent 67dd6f5956
commit b9f04a556e
2 changed files with 3 additions and 2 deletions

View File

@ -2612,7 +2612,8 @@ bool AsmParser::parseDirectiveFill() {
for (uint64_t i = 0, e = NumValues; i != e; ++i) {
getStreamer().EmitIntValue(FillExpr, NonZeroFillSize);
getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
if (NonZeroFillSize < FillSize)
getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
}
return false;

View File

@ -72,7 +72,7 @@ void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) {
/// EmitIntValue - Special case of EmitValue that avoids the client having to
/// pass in a MCExpr for constant integers.
void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
assert(Size <= 8 && "Invalid size");
assert(1 <= Size && Size <= 8 && "Invalid size");
assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
"Invalid size");
char buf[8];