commit a1e9f32757d57dc72247e20cd6b747fa242736b3
parent b3708634dbc943051bab77b564bd255b8df04f27
Author: Florian Dold <florian@dold.me>
Date: Thu, 2 Feb 2023 02:29:09 +0100
fix memory leaks
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tart_module.c b/tart_module.c
@@ -792,6 +792,7 @@ kdf_mod_mpi(mbedtls_mpi *r,
}
mbedtls_mpi_free (r);
}
+ free(my_ctx);
}
@@ -1035,8 +1036,8 @@ rsa_verify(const HashCode *hash,
}
cleanup:
- mbedtls_mpi_init(&r);
- mbedtls_mpi_init(&sig_2);
+ mbedtls_mpi_free(&r);
+ mbedtls_mpi_free(&sig_2);
return ret;
}
@@ -1053,7 +1054,7 @@ static JSValue js_talercrypto_rsa_blind(JSContext *ctx, JSValueConst this_val,
size_t rsa_enc_len;
RsaPub rsa_pub;
JSValue ret_val = JS_UNDEFINED;
- uint8_t *out_buf;
+ uint8_t *out_buf = NULL;
size_t out_len;
rsa_public_key_init(&rsa_pub);
@@ -1084,6 +1085,10 @@ static JSValue js_talercrypto_rsa_blind(JSContext *ctx, JSValueConst this_val,
ret_val = make_js_ta_copy(ctx, out_buf, out_len);
cleanup:
+ if (NULL != out_buf) {
+ free(out_buf);
+ out_buf = NULL;
+ }
rsa_public_key_free(&rsa_pub);
return ret_val;
}
@@ -1202,6 +1207,7 @@ static JSValue js_structured_clone(JSContext *ctx, JSValueConst this_val,
}
obj = JS_ReadObject(ctx, buf, len, JS_WRITE_OBJ_REFERENCE);
+ js_free(ctx, buf);
return obj;
}