summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2014-04-30 09:33:50 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2014-04-30 09:33:50 +0000
commit5f4aba6c8a73b51f583da7f4823c04531bfeb2ab (patch)
treedc7fc14a36d8592a78919cc4bde5fecaac94170b /include
parent5b188b1cb8de7b7973aceecef08ee5ce44ee2cfc (diff)
downloadllvm-5f4aba6c8a73b51f583da7f4823c04531bfeb2ab.tar.gz
llvm-5f4aba6c8a73b51f583da7f4823c04531bfeb2ab.tar.bz2
llvm-5f4aba6c8a73b51f583da7f4823c04531bfeb2ab.tar.xz
raw_ostream::operator<<(StringRef): Avoid potential overflow in pointer arithmetic.
(OutBufCur + Size) might overflow if Size were large. For example on i686-linux, OutBufCur: 0xFFFDF27D OutBufEnd: 0xFFFDF370 Size: 0x0002BF20 (180,000) It caused flaky error in MC/COFF/section-name-encoding.s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/raw_ostream.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h
index 94e4b19b7a..34fbe082cd 100644
--- a/include/llvm/Support/raw_ostream.h
+++ b/include/llvm/Support/raw_ostream.h
@@ -162,7 +162,7 @@ public:
size_t Size = Str.size();
// Make sure we can use the fast path.
- if (OutBufCur+Size > OutBufEnd)
+ if (Size > (size_t)(OutBufEnd - OutBufCur))
return write(Str.data(), Size);
memcpy(OutBufCur, Str.data(), Size);