westcos-tool.c:fix memory leaks in dst->modulus.data and dst->exponent.data

Signed-off-by: whzhe <wanghongzhe@huawei.com>
This commit is contained in:
w00475903 2020-10-11 23:28:41 -04:00 committed by Frank Morgner
parent d0c44b9ddc
commit 7551e14c58
1 changed files with 6 additions and 1 deletions

View File

@ -673,11 +673,16 @@ int main(int argc, char *argv[])
if (!do_convert_bignum(&dst->modulus, rsa_n)
|| !do_convert_bignum(&dst->exponent, rsa_e))
{
free(dst->modulus.data);
free(dst->exponent.data);
goto out;
}
}
r = sc_pkcs15_encode_pubkey(ctx, &key, &pdata, &lg);
free(dst->modulus.data);
free(dst->exponent.data);
if(r) goto out;
printf("Public key length %"SC_FORMAT_LEN_SIZE_T"d\n", lg);