RAND: fix memory leak

pb_init() which is called by init_polynom_size() will call
mp_init_copy() on chara which means that chara being a pointer
itself is useless. We can clear it directly after it has been
copied.
This commit is contained in:
hasufell 2014-04-15 14:15:41 +02:00
parent bbe2d89a5b
commit 617e32b9cf
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020

View File

@ -80,10 +80,11 @@ static mp_digit get_urnd_int_small(int *sign)
*/
pb_poly *ntru_get_urnd_poly_small(ntru_context *ctx)
{
mp_int *chara = malloc(sizeof(mp_int));
init_integer(chara);
mp_int chara;
init_integer(&chara);
pb_poly *poly = malloc(sizeof(pb_poly));
init_polynom_size(poly, chara, ctx->N);
init_polynom_size(poly, &chara, ctx->N);
mp_clear(&chara);
for (int i = 0; i < ctx->N; i++) {
int sign;