From f0d71f9df0b6b82b92131d5146b5cf896596d748 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 25 Apr 2013 15:54:25 -0700 Subject: [PATCH] Check allocate() return code. --- .../crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c b/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c index 42df4167..3137b7ad 100644 --- a/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +++ b/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c @@ -34,7 +34,7 @@ allocate(void) k2 = _sodium_alignedcalloc(&k2_, crypto_onetimeauth_KEYBYTES + crypto_onetimeauth_BYTES); - return !(h && m && k && h2 && m2 && k2); + return -!(h && m && k && h2 && m2 && k2); } static void @@ -143,7 +143,9 @@ crypto_onetimeauth_pick_best_implementation(void) (implementations[i]) != 0) { continue; } - allocate(); + if (allocate() != 0) { + return NULL; + } err = checksum_compute(); deallocate(); if (err == NULL && strcmp(checksum, CHECKSUM) == 0) {