diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:34:38 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:34:38 +0000 | 
| commit | 69156b4c20249e7800cc09e0eef0beb3d15ac1ad (patch) | |
| tree | 461d3cf041290f4a99740d540bf0973d6084f98e /lib/Support/MemoryBuffer.cpp | |
| parent | ee8648bdac07986a0f1ec897b02ec82a2f144d46 (diff) | |
Notes
Diffstat (limited to 'lib/Support/MemoryBuffer.cpp')
| -rw-r--r-- | lib/Support/MemoryBuffer.cpp | 3 | 
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index 98862e96b749..d09ef3a4c0bc 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -57,7 +57,8 @@ void MemoryBuffer::init(const char *BufStart, const char *BufEnd,  /// CopyStringRef - Copies contents of a StringRef into a block of memory and  /// null-terminates it.  static void CopyStringRef(char *Memory, StringRef Data) { -  memcpy(Memory, Data.data(), Data.size()); +  if (!Data.empty()) +    memcpy(Memory, Data.data(), Data.size());    Memory[Data.size()] = 0; // Null terminate string.  }  | 
