]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
UBSan: Avoid memcpy(ptr, NULL, 0)
authorJouni Malinen <j@w1.fi>
Sat, 23 Feb 2019 12:01:25 +0000 (14:01 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 25 Feb 2019 17:48:49 +0000 (19:48 +0200)
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>
src/utils/os_unix.c

index acc6975587422181b1588f9041a8f2f23d93ad24..800c50772d893852b231f09d873544f57a61397b 100644 (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;
 }