From d1e818dd48900f423834b00ee6c397e0c5154c20 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Thu, 3 Nov 2016 15:55:26 -0600 Subject: [PATCH] Modify arg passing to retain NULL assignment --- certgen/test.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/certgen/test.c b/certgen/test.c index 7c28b645..4588689d 100644 --- a/certgen/test.c +++ b/certgen/test.c @@ -8,7 +8,8 @@ #define HEAP_HINT NULL #define FOURK_SZ 4096 -void free_things(byte* a, byte* b, byte* c, ecc_key* d, ecc_key* e, WC_RNG* f); +void free_things(byte** a, byte** b, byte** c, ecc_key* d, ecc_key* e, + WC_RNG* f); int main(void) { @@ -183,29 +184,30 @@ int main(void) { goto success; fail: - free_things(derBuf, pemBuf, caKeyBuf, &caKey, &newKey, &rng); + free_things(&derBuf, &pemBuf, &caKeyBuf, &caKey, &newKey, &rng); printf("Failure code was %d\n", ret); return -1; success: - free_things(derBuf, pemBuf, caKeyBuf, &caKey, &newKey, &rng); + free_things(&derBuf, &pemBuf, &caKeyBuf, &caKey, &newKey, &rng); printf("Tests passed\n"); return 0; } -void free_things(byte* a, byte* b, byte* c, ecc_key* d, ecc_key* e, WC_RNG* f) +void free_things(byte** a, byte** b, byte** c, ecc_key* d, ecc_key* e, + WC_RNG* f) { - if (a != NULL) { - XFREE(a, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - a = NULL; + if (*a != NULL) { + XFREE(*a, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + *a = NULL; } - if (b != NULL) { - XFREE(b, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - b = NULL; + if (*b != NULL) { + XFREE(*b, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + *b = NULL; } - if (c != NULL) { - XFREE(c, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - c = NULL; + if (*c != NULL) { + XFREE(*c, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + *c = NULL; } wc_ecc_free(d);