[Spice-devel] [PATCH 3/8] common: spice_memdup could accept NULL

Marc-André Lureau marcandre.lureau at redhat.com
Tue May 3 07:37:40 PDT 2011


(this patch is not to solve a crash fix, but to align with glib API)
---
 common/mem.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/common/mem.c b/common/mem.c
index 96be351..7236cf0 100644
--- a/common/mem.c
+++ b/common/mem.c
@@ -74,6 +74,10 @@ void *spice_memdup(const void *mem, size_t n_bytes)
 {
     void *copy;
 
+    if (mem == NULL) {
+        return NULL;
+    }
+
     copy = spice_malloc(n_bytes);
     memcpy(copy, mem, n_bytes);
     return copy;
-- 
1.7.4



More information about the Spice-devel mailing list