From fc80f096e4b0432f873807c6d5d7a66ebb345323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 25 Jan 2011 16:17:12 +0100 Subject: [PATCH] common: spice_memdup could accept NULL (this patch is not to solve a crash fix, but to align with glib API) --- common/mem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/mem.c b/common/mem.c index 96be351c..7236cf0c 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;