From d556a56c3cd5dbfca7c8e14c81c57414a780e24b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 25 Nov 2014 16:19:20 -0800 Subject: [PATCH] Add extra assert() in tests allocating memory on the heap. --- test/default/pwhash.c | 2 ++ test/default/sodium_utils2.c | 2 ++ test/default/sodium_utils3.c | 1 + 3 files changed, 5 insertions(+) diff --git a/test/default/pwhash.c b/test/default/pwhash.c index 41397f43..6f1dd3c1 100644 --- a/test/default/pwhash.c +++ b/test/default/pwhash.c @@ -267,8 +267,10 @@ static void tv3(void) do { out = (char *) sodium_malloc(strlen(tests[i].out) + 1U); + assert(out != NULL); memcpy(out, tests[i].out, strlen(tests[i].out) + 1U); passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U); + assert(passwd != NULL); memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U); if (crypto_pwhash_scryptsalsa208sha256_str_verify( out, passwd, strlen(passwd)) != 0) { diff --git a/test/default/sodium_utils2.c b/test/default/sodium_utils2.c index dc3a7a0b..78c6f45e 100644 --- a/test/default/sodium_utils2.c +++ b/test/default/sodium_utils2.c @@ -48,6 +48,7 @@ int main(void) for (i = 0U; i < 10000U; i++) { size = randombytes_uniform(100000U); buf = sodium_malloc(size); + assert(buf != NULL); memset(buf, i, size); sodium_mprotect_readonly(buf); sodium_free(buf); @@ -65,6 +66,7 @@ int main(void) #endif size = randombytes_uniform(100000U); buf = sodium_malloc(size); + assert(buf != NULL); sodium_mprotect_readonly(buf); sodium_mprotect_readwrite(buf); #ifndef __EMSCRIPTEN__ diff --git a/test/default/sodium_utils3.c b/test/default/sodium_utils3.c index 5a8344f2..281c7d56 100644 --- a/test/default/sodium_utils3.c +++ b/test/default/sodium_utils3.c @@ -43,6 +43,7 @@ int main(void) #endif size = randombytes_uniform(100000U); buf = sodium_malloc(size); + assert(buf != NULL); sodium_mprotect_noaccess(buf); sodium_mprotect_readwrite(buf); #ifndef __EMSCRIPTEN__