_set_cacert() calls mbedtls_x509_crt_init(&crt) followed by mbedtls_x509_crt_parse(), which allocates internal storage (parsed cert fields, chain links, raw buffers) inside the crt object. The function then returns on both the error and success paths without calling mbedtls_x509_crt_free(&crt), so all of that internal state is leaked when the stack-allocated crt goes out of scope. Every invocation of "wget cacert ..." leaks memory. Free the cert object on both return paths. Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@gmail.com> Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>