From e6398998b1863f69b7cd5665a4ed6e515fbb0eb5 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Mon, 4 Jan 2016 12:55:35 -0700 Subject: [PATCH] check for NULL after malloc in posix_memalign --- wolfssl/test.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/wolfssl/test.h b/wolfssl/test.h index ebe722432..1e4fa1373 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -1374,7 +1374,7 @@ typedef THREAD_RETURN WOLFSSL_THREAD (*thread_func)(void* args); static INLINE void StackSizeCheck(func_args* args, thread_func tf) { int ret, i, used; - unsigned char* myStack = NULL; + unsigned char* myStack; int stackSize = 1024*128; pthread_attr_t myAttr; pthread_t threadId; @@ -1385,14 +1385,11 @@ static INLINE void StackSizeCheck(func_args* args, thread_func tf) #endif ret = posix_memalign((void**)&myStack, sysconf(_SC_PAGESIZE), stackSize); - if (ret != 0) + if (ret != 0 || myStack == NULL) err_sys("posix_memalign failed\n"); XMEMSET(myStack, 0x01, stackSize); - if (myStack == NULL) - err_sys("Failed to initialize myStack"); - ret = pthread_attr_init(&myAttr); if (ret != 0) err_sys("attr_init failed");