If an error occurs while reading the second bignum we leak the memory
allocated for the first bignum.
return -E_BIGNUM;
ret = read_bignum(p, end - p, &e);
if (ret < 0)
- goto fail;
+ goto free_rsa;
p += ret;
ret = read_bignum(p, end - p, &n);
if (ret < 0)
- goto fail;
+ goto free_e;
#ifdef HAVE_RSA_SET0_KEY
RSA_set0_key(rsa, n, e, NULL);
#else
#endif
*result = rsa;
return 1;
-fail:
+free_e:
+ BN_free(e);
+free_rsa:
RSA_free(rsa);
return ret;
}