aboutsummaryrefslogtreecommitdiffstats
path: root/src/libtls/tls_protection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libtls/tls_protection.c')
-rw-r--r--src/libtls/tls_protection.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libtls/tls_protection.c b/src/libtls/tls_protection.c
index a92e902e5..abcc42064 100644
--- a/src/libtls/tls_protection.c
+++ b/src/libtls/tls_protection.c
@@ -256,7 +256,16 @@ METHOD(tls_protection_t, build, status_t,
*data = chunk_cat("mmcc", *data, mac, padding,
chunk_from_thing(padding_length));
/* encrypt inline */
- this->crypter_out->encrypt(this->crypter_out, *data, iv, NULL);
+ if (!this->crypter_out->encrypt(this->crypter_out, *data,
+ iv, NULL))
+ {
+ if (!this->iv_out.len)
+ {
+ free(iv.ptr);
+ }
+ free(data->ptr);
+ return FAILED;
+ }
if (this->iv_out.len)
{ /* next record IV is last ciphertext block of this record */