From 136df6bd999aa72d4a3817f719bcb87f86014490 Mon Sep 17 00:00:00 2001 From: Aaron Green Date: Fri, 12 Feb 2016 08:15:35 -0800 Subject: [PATCH] Fix implementation-specific behavior in gcm_test.c gcm_test.c includes a test case that does a 'malloc(0)'. This test case currently fails if malloc(0) returns NULL. According to the standard, malloc's behavior with a size of 0is implementation specific and may either be NULL or another pointer suitable to be passed to free(). This change modifies gcm_test.c to handle a return value of NULL. It has been tested with a custom allocator on an experimental branch. Change-Id: I35514ec9735cedffc621f7dfae42b4c6664a1766 Reviewed-on: https://boringssl-review.googlesource.com/7122 Reviewed-by: Adam Langley --- crypto/modes/gcm_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/modes/gcm_test.c b/crypto/modes/gcm_test.c index 9414ac6e..e5433482 100644 --- a/crypto/modes/gcm_test.c +++ b/crypto/modes/gcm_test.c @@ -336,7 +336,7 @@ static int run_test_case(unsigned test_num, const struct test_case *test) { } out = OPENSSL_malloc(plaintext_len); - if (out == NULL) { + if (plaintext_len != 0 && out == NULL) { goto out; } if (AES_set_encrypt_key(key, key_len*8, &aes_key)) {