Avoid memcmp() with len=0

This commit is contained in:
Frank Denis 2022-12-12 00:16:51 +01:00
parent fbad6b933b
commit 3cbaea8bc6

View File

@ -3283,7 +3283,7 @@ tv2(void)
NULL, 0, nonce, key) != 0) { NULL, 0, nonce, key) != 0) {
printf("Decryption of random ciphertext failed"); printf("Decryption of random ciphertext failed");
} }
assert(memcmp(message, message2, message_len) == 0); assert(message_len == 0 || memcmp(message, message2, message_len) == 0);
sodium_free(key); sodium_free(key);
sodium_free(nonce); sodium_free(nonce);
sodium_free(ciphertext); sodium_free(ciphertext);