mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-15 09:33:39 +00:00
Fix integer overflow bug in raw_ostream::write. This showed up as a
non-deterministic crash in the test suite. Fixes PR10055! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138717 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f5ec9b55e8
commit
b1b051ec97
@ -84,7 +84,7 @@ void raw_ostream::SetBuffered() {
|
||||
}
|
||||
|
||||
void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
|
||||
BufferKind Mode) {
|
||||
BufferKind Mode) {
|
||||
assert(((Mode == Unbuffered && BufferStart == 0 && Size == 0) ||
|
||||
(Mode != Unbuffered && BufferStart && Size)) &&
|
||||
"stream must be unbuffered or have at least one byte");
|
||||
@ -284,7 +284,7 @@ raw_ostream &raw_ostream::write(unsigned char C) {
|
||||
|
||||
raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) {
|
||||
// Group exceptional cases into a single branch.
|
||||
if (BUILTIN_EXPECT(OutBufCur+Size > OutBufEnd, false)) {
|
||||
if (BUILTIN_EXPECT(size_t(OutBufEnd - OutBufCur) < Size, false)) {
|
||||
if (BUILTIN_EXPECT(!OutBufStart, false)) {
|
||||
if (BufferMode == Unbuffered) {
|
||||
write_impl(Ptr, Size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user