From 8a8463e4ac60a6df291c675f222ea0aff0573d5f Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 8 May 2014 15:06:28 -0700 Subject: [PATCH] Plug memory leak on error path in the easy interfaces --- src/libsodium/crypto_box/crypto_box_easy.c | 1 + src/libsodium/crypto_secretbox/crypto_secretbox_easy.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libsodium/crypto_box/crypto_box_easy.c b/src/libsodium/crypto_box/crypto_box_easy.c index 80da4333..d39bbbba 100644 --- a/src/libsodium/crypto_box/crypto_box_easy.c +++ b/src/libsodium/crypto_box/crypto_box_easy.c @@ -73,6 +73,7 @@ crypto_box_open_easy(unsigned char *m, const unsigned char *c, memcpy(c_boxed + crypto_box_BOXZEROBYTES, c, clen); m_boxed_len = c_boxed_len + crypto_box_MACBYTES; if ((m_boxed = (unsigned char *) malloc(m_boxed_len)) == NULL) { + free(c_boxed); return -1; } rc = crypto_box_open(m_boxed, c_boxed, diff --git a/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c b/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c index e64aae05..9d03860f 100644 --- a/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +++ b/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c @@ -74,6 +74,7 @@ crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c, memcpy(c_boxed + crypto_secretbox_BOXZEROBYTES, c, clen); m_boxed_len = c_boxed_len + crypto_secretbox_MACBYTES; if ((m_boxed = (unsigned char *) malloc(m_boxed_len)) == NULL) { + free(c_boxed); return -1; } rc = crypto_secretbox_open(m_boxed, c_boxed,