[Spice-devel] [PATCH 1/4] client controller/foreign_menu: use memmove instead of memcpy in readers

Uri Lublin uril at redhat.com
Tue Dec 20 08:52:02 PST 2011


When src/dst memory areas may overlap, it's safer to use memmove.
---
 client/controller.cpp   |    2 +-
 client/foreign_menu.cpp |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/client/controller.cpp b/client/controller.cpp
index e7c4b95..91c0021 100644
--- a/client/controller.cpp
+++ b/client/controller.cpp
@@ -216,7 +216,7 @@ bool ControllerConnection::read_msgs()
         pos += hdr->size;
     }
     if (nread > 0 && pos != _read_buf) {
-        memcpy(_read_buf, pos, nread);
+        memmove(_read_buf, pos, nread);
     }
     _read_pos = _read_buf + nread;
     return true;
diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp
index 926e266..00cc57c 100644
--- a/client/foreign_menu.cpp
+++ b/client/foreign_menu.cpp
@@ -237,7 +237,7 @@ bool ForeignMenuConnection::read_msgs()
         pos += hdr->size;
     }
     if (nread > 0 && pos != _read_buf) {
-        memcpy(_read_buf, pos, nread);
+        memmove(_read_buf, pos, nread);
     }
     _read_pos = _read_buf + nread;
     return true;
-- 
1.7.1



More information about the Spice-devel mailing list