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:
parent
bbe2d89a5b
commit
617e32b9cf
@ -80,10 +80,11 @@ static mp_digit get_urnd_int_small(int *sign)
|
|||||||
*/
|
*/
|
||||||
pb_poly *ntru_get_urnd_poly_small(ntru_context *ctx)
|
pb_poly *ntru_get_urnd_poly_small(ntru_context *ctx)
|
||||||
{
|
{
|
||||||
mp_int *chara = malloc(sizeof(mp_int));
|
mp_int chara;
|
||||||
init_integer(chara);
|
init_integer(&chara);
|
||||||
pb_poly *poly = malloc(sizeof(pb_poly));
|
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++) {
|
for (int i = 0; i < ctx->N; i++) {
|
||||||
int sign;
|
int sign;
|
||||||
|
Loading…
Reference in New Issue
Block a user