From b3f25b06e0ae2821e7b9b6f6a10fb0a51b7f2445 Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Tue, 22 Feb 2022 07:50:47 -0500 Subject: [PATCH] Add header guard around malloc(0) returning NULL implementation Make it safe to import the config multiple times without having multiple definition errors. (This prevents errors in the fuzzers in a later patch.) Signed-off-by: Daniel Axtens --- tests/configs/config-wrapper-malloc-0-null.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/configs/config-wrapper-malloc-0-null.h b/tests/configs/config-wrapper-malloc-0-null.h index 69a9578c6..add1a787b 100644 --- a/tests/configs/config-wrapper-malloc-0-null.h +++ b/tests/configs/config-wrapper-malloc-0-null.h @@ -24,6 +24,8 @@ #include "mbedtls/config.h" #include + +#ifndef MBEDTLS_PLATFORM_STD_CALLOC static inline void *custom_calloc( size_t nmemb, size_t size ) { if( nmemb == 0 || size == 0 ) @@ -33,5 +35,6 @@ static inline void *custom_calloc( size_t nmemb, size_t size ) #define MBEDTLS_PLATFORM_MEMORY #define MBEDTLS_PLATFORM_STD_CALLOC custom_calloc +#endif #endif /* MBEDTLS_CONFIG_H */