[llvm] r241617 - Don't pass a null pointer to memcpy.

Rafael Espindola rafael.espindola at gmail.com
Tue Jul 7 12:00:02 PDT 2015


Author: rafael
Date: Tue Jul  7 14:00:02 2015
New Revision: 241617

URL: http://llvm.org/viewvc/llvm-project?rev=241617&view=rev
Log:
Don't pass a null pointer to memcpy.

Fixes pr23650.

Modified:
    llvm/trunk/include/llvm/Support/raw_ostream.h

Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=241617&r1=241616&r2=241617&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Tue Jul  7 14:00:02 2015
@@ -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;
   }
 





More information about the llvm-commits mailing list