From 51f5a1a8fee29bd2414b8799f3120cc0746ed906 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 7 Jul 2015 19:00:02 +0000 Subject: [PATCH] Don't pass a null pointer to memcpy. Fixes pr23650. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241617 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/raw_ostream.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index b59317112c4..28e512c8694 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -165,8 +165,10 @@ public: if (Size > (size_t)(OutBufEnd - OutBufCur)) return write(Str.data(), Size); - memcpy(OutBufCur, Str.data(), Size); - OutBufCur += Size; + if (Size) { + memcpy(OutBufCur, Str.data(), Size); + OutBufCur += Size; + } return *this; } -- 2.34.1