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 <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-02-23 14:01:25 +02:00
parent 5a23c2528a
commit a9377bc380

View File

@ -1,6 +1,6 @@
/*
* OS specific functions for UNIX/POSIX systems
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
* Copyright (c) 2005-2019, Jouni Malinen <j@w1.fi>
*
* 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;
}