From b6a9c38950bb8464f316eb066d3122d749b90289 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Tue, 6 Aug 2024 14:48:34 -0400 Subject: [PATCH] Addressing PR comments --- IDE/CRYPTOCELL/user_settings.h | 1 + IDE/GCC-ARM/Header/user_settings.h | 1 + IDE/NETOS/user_settings.h | 1 + IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h | 1 + IDE/STARCORE/user_settings.h | 1 + IDE/SimplicityStudio/user_settings.h | 1 + IDE/WICED-STUDIO/user_settings.h | 1 + IDE/WINCE/user_settings.h | 1 + IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h | 1 + IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h | 1 + IDE/XCODE-FIPSv2/user_settings.h | 1 + IDE/XCODE-FIPSv5/user_settings.h | 1 + examples/configs/user_settings_template.h | 1 + wolfssl/wolfcrypt/types.h | 8 +++++++- 14 files changed, 20 insertions(+), 1 deletion(-) diff --git a/IDE/CRYPTOCELL/user_settings.h b/IDE/CRYPTOCELL/user_settings.h index 3f1866e90e..b6ffe4c781 100644 --- a/IDE/CRYPTOCELL/user_settings.h +++ b/IDE/CRYPTOCELL/user_settings.h @@ -401,6 +401,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/GCC-ARM/Header/user_settings.h b/IDE/GCC-ARM/Header/user_settings.h index e3a0922997..40986b08b4 100644 --- a/IDE/GCC-ARM/Header/user_settings.h +++ b/IDE/GCC-ARM/Header/user_settings.h @@ -419,6 +419,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/NETOS/user_settings.h b/IDE/NETOS/user_settings.h index 957cf82b01..efdbf01614 100644 --- a/IDE/NETOS/user_settings.h +++ b/IDE/NETOS/user_settings.h @@ -410,6 +410,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h index d3f3de9444..75d5f54d22 100644 --- a/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h +++ b/IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h @@ -397,6 +397,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/STARCORE/user_settings.h b/IDE/STARCORE/user_settings.h index 8706865706..df74dbee70 100644 --- a/IDE/STARCORE/user_settings.h +++ b/IDE/STARCORE/user_settings.h @@ -417,6 +417,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/SimplicityStudio/user_settings.h b/IDE/SimplicityStudio/user_settings.h index a02cbd54d7..05ba8d517d 100644 --- a/IDE/SimplicityStudio/user_settings.h +++ b/IDE/SimplicityStudio/user_settings.h @@ -337,6 +337,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/WICED-STUDIO/user_settings.h b/IDE/WICED-STUDIO/user_settings.h index 927e7091f6..e4a6f2e8a5 100644 --- a/IDE/WICED-STUDIO/user_settings.h +++ b/IDE/WICED-STUDIO/user_settings.h @@ -411,6 +411,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/WINCE/user_settings.h b/IDE/WINCE/user_settings.h index 02157f2a54..eca61f0436 100644 --- a/IDE/WINCE/user_settings.h +++ b/IDE/WINCE/user_settings.h @@ -491,6 +491,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h b/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h index 615c8beb6e..cbbdfe3a0e 100644 --- a/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h +++ b/IDE/XCODE-FIPSv2/macOS-C++/Intel/user_settings.h @@ -407,6 +407,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h b/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h index 494348d1b6..768ed06c2a 100644 --- a/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h +++ b/IDE/XCODE-FIPSv2/macOS-C++/M1/user_settings.h @@ -418,6 +418,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv2/user_settings.h b/IDE/XCODE-FIPSv2/user_settings.h index 030cd5807d..cf039344df 100644 --- a/IDE/XCODE-FIPSv2/user_settings.h +++ b/IDE/XCODE-FIPSv2/user_settings.h @@ -419,6 +419,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/IDE/XCODE-FIPSv5/user_settings.h b/IDE/XCODE-FIPSv5/user_settings.h index a66b0dce70..74fdb284e2 100644 --- a/IDE/XCODE-FIPSv5/user_settings.h +++ b/IDE/XCODE-FIPSv5/user_settings.h @@ -500,6 +500,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/examples/configs/user_settings_template.h b/examples/configs/user_settings_template.h index b7c0700b6e..680376ad2d 100644 --- a/examples/configs/user_settings_template.h +++ b/examples/configs/user_settings_template.h @@ -354,6 +354,7 @@ extern "C" { /* prototypes for user heap override functions */ /* Note: Realloc only required for normal math */ + /* Note2: XFREE(NULL) must be properly handled */ #include /* for size_t */ extern void *myMalloc(size_t n, void* heap, int type); extern void myFree(void *p, void* heap, int type); diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 5292168116..a540699e64 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -437,7 +437,13 @@ typedef struct w64wrapper { /* idea to add global alloc override by Moises Guimaraes */ /* default to libc stuff */ /* XREALLOC is used once in normal math lib, not in fast math lib */ - /* XFREE on some embedded systems doesn't like free(0) so test */ + /* XFREE on some embedded systems doesn't like free(0) so test for NULL + * explicitly. + * + * For example: + * #define XFREE(p, h, t) \ + * {void* xp = (p); if (xp != NULL) free(xp, h, t);} + */ #if defined(HAVE_IO_POOL) WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type); WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);