[Lldb-commits] [PATCH] D39578: Fix a couple of self-assignments using memcpy.

Phabricator via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 14 10:20:00 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL318164: Add check for self-assignment.  NFC (authored by dhinton).

Repository:
  rL LLVM

https://reviews.llvm.org/D39578

Files:
  lldb/trunk/source/Core/RegisterValue.cpp
  lldb/trunk/source/Core/Value.cpp


Index: lldb/trunk/source/Core/Value.cpp
===================================================================
--- lldb/trunk/source/Core/Value.cpp
+++ lldb/trunk/source/Core/Value.cpp
@@ -142,6 +142,9 @@
 }
 
 size_t Value::AppendDataToHostBuffer(const Value &rhs) {
+  if (this == &rhs)
+    return 0;
+
   size_t curr_size = m_data_buffer.GetByteSize();
   Status error;
   switch (rhs.GetValueType()) {
Index: lldb/trunk/source/Core/RegisterValue.cpp
===================================================================
--- lldb/trunk/source/Core/RegisterValue.cpp
+++ lldb/trunk/source/Core/RegisterValue.cpp
@@ -539,6 +539,9 @@
 }
 
 bool RegisterValue::CopyValue(const RegisterValue &rhs) {
+  if (this == &rhs)
+    return rhs.m_type == eTypeInvalid ? false : true;
+
   m_type = rhs.m_type;
   switch (m_type) {
   case eTypeInvalid:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39578.122868.patch
Type: text/x-patch
Size: 839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171114/923b51c5/attachment.bin>


More information about the lldb-commits mailing list