Skip to content

Commit c64fd4f

Browse files
authored
Merge pull request #9905 from julek-wolfssl/WC_ALLOC_DO_ON_FAILURE-cleanup
Don't declare WC_ALLOC_DO_ON_FAILURE by default
2 parents 73bea90 + 5f4d499 commit c64fd4f

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

tests/api/test_aes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include <tests/api/api.h>
3535
#include <tests/api/test_aes.h>
3636

37+
#define WC_ALLOC_DO_ON_FAILURE() WC_DO_NOTHING
38+
3739
/*******************************************************************************
3840
* AES
3941
******************************************************************************/

tests/api/test_chacha.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ int test_wc_Chacha_Process_Chunking(void)
334334
0x0c, 0xb3, 0xc9, 0x39, 0x0f, 0x1f, 0x51, 0x9d
335335
};
336336

337-
WC_ALLOC_VAR(plain, byte, CHACHA_LEN, NULL);
338-
WC_ALLOC_VAR(cipher, byte, CHACHA_LEN, NULL);
337+
WC_ALLOC_VAR_EX(plain, byte, CHACHA_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER,
338+
ExpectNotNull(plain); goto cleanup);
339+
WC_ALLOC_VAR_EX(cipher, byte, CHACHA_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER,
340+
ExpectNotNull(cipher); goto cleanup);
339341

340342
XMEMSET(plain, 0xa5, CHACHA_LEN);
341343
for (i = 0; i < (int)sizeof(key); i++) {
@@ -360,8 +362,11 @@ int test_wc_Chacha_Process_Chunking(void)
360362
ExpectBufEQ(cipher, expected, (int)sizeof(expected));
361363
}
362364

363-
WC_FREE_VAR(plain, NULL);
364-
WC_FREE_VAR(cipher, NULL);
365+
#ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC
366+
cleanup:
367+
#endif
368+
WC_FREE_VAR_EX(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);
369+
WC_FREE_VAR_EX(cipher, NULL, DYNAMIC_TYPE_TMP_BUFFER);
365370
#endif
366371
return EXPECT_RESULT();
367372
} /* END test_wc_Chacha_Process */

tests/api/test_rsa.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <tests/api/api.h>
3434
#include <tests/api/test_rsa.h>
3535

36+
#define WC_ALLOC_DO_ON_FAILURE() WC_DO_NOTHING
37+
3638
/*
3739
* Testing wc_Init RsaKey()
3840
*/

wolfcrypt/test/test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp80056c_twostep_cmac(void)
18921892
}
18931893
#endif
18941894

1895+
#define WC_ALLOC_DO_ON_FAILURE() WC_DO_NOTHING
1896+
18951897
#ifdef TEST_ALWAYS_RUN_TO_END
18961898
#define TEST_FAIL(msg, retval) do { last_failed_test_ret = (retval); wc_test_render_error_message(msg, retval); } while (0)
18971899
#elif !defined(TEST_FAIL)

wolfssl/wolfcrypt/types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,6 @@ enum {
825825
#include <wolfssl/wolfcrypt/memory.h>
826826

827827
/* declare/free variable handling for async and smallstack */
828-
#ifndef WC_ALLOC_DO_ON_FAILURE
829-
#define WC_ALLOC_DO_ON_FAILURE() WC_DO_NOTHING
830-
#endif
831828

832829
#define WC_DECLARE_HEAP_ARRAY(VAR_NAME, VAR_TYPE, VAR_ITEMS, VAR_SIZE, HEAP) \
833830
VAR_TYPE* VAR_NAME[VAR_ITEMS] = { NULL, }; \

0 commit comments

Comments
 (0)