Skip to content

Commit

Permalink
Fixing memory management bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Oct 9, 2024
1 parent 42a12b9 commit f238923
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/bn/relic_bn_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,14 @@ void bn_rec_sac(int8_t *b, size_t *len, bn_t *k, size_t c, size_t m, size_t n) {
}

RLC_TRY {
fp_prime_get_par(t[0]);
l = RLC_MAX(l, bn_bits(t[0]) + 1);
for (size_t i = 0; i < m; i++) {
bn_null(t[i]);
bn_new(t[i]);
}

fp_prime_get_par(t[0]);
l = RLC_MAX(l, bn_bits(t[0]) + 1);
for (size_t i = 0; i < m; i++) {
bn_copy(t[i], k[i]);
/* The current basis for some curves might be one bit longer. */
if (ep_curve_is_pairf() == EP_BN) {
Expand Down
3 changes: 2 additions & 1 deletion src/cp/relic_cp_bls.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ int cp_bls_agg_sig(g1_t sig, g2_t a, const g1_t s, const g2_t q) {
RLC_THROW(ERR_NO_MEMORY);
}
bn_new(t);
g1_new(p);
g1_new(u);
g2_new(p);

md_map(h, buf, g2_size_bin(q, 0));
bn_read_bin(t, h, RLC_MIN(RLC_MD_LEN, RLC_CEIL(pc_param_level(), 8)));
Expand Down
5 changes: 3 additions & 2 deletions src/cp/relic_cp_pcdel.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@ int cp_ambat_ans(gt_t *gs, const g2_t *rs, const g1_t a, const g2_t b,
}
g1_norm(ps[0], ps[0]);
g2_copy(qs[0], b);
g1_copy(ps[1], a);
g2_mul_gen(qs[1], d);
g1_mul(ps[1], a, d);
g2_get_gen(qs[1]);

pc_map_sim(gs[m], ps, qs, 2);
} RLC_CATCH_ANY {
Expand Down Expand Up @@ -965,6 +965,7 @@ int cp_amprd_ask(bn_t d, g2_t *ds, g1_t a1, g2_t b1, g1_t a2, g2_t b2,

RLC_TRY {
g1_new(t);
g1_new(a);

g1_set_infty(a);
for (size_t i = 0; i < m; i++) {
Expand Down

0 comments on commit f238923

Please sign in to comment.