From a9377bc380d870baed60ce6e29370e6df46cd037 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 23 Feb 2019 14:01:25 +0200 Subject: [PATCH] UBSan: Avoid memcpy(ptr, NULL, 0) This results in an UBSan warning that can be avoided easily. os_unix.c:524:3: runtime error: null pointer passed as argument 2, which is declared to never be null Signed-off-by: Jouni Malinen --- src/utils/os_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index acc697558..800c50772 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -1,6 +1,6 @@ /* * OS specific functions for UNIX/POSIX systems - * Copyright (c) 2005-2009, Jouni Malinen + * Copyright (c) 2005-2019, Jouni Malinen * * This software may be distributed under the terms of the BSD license. * See README for more details. @@ -520,7 +520,7 @@ void * os_memdup(const void *src, size_t len) { void *r = os_malloc(len); - if (r) + if (r && src) os_memcpy(r, src, len); return r; }