test: Use checked_alloc
This commit is contained in:
parent
9d560f992d
commit
5eb030ca41
16
src/tests.c
16
src/tests.c
|
@ -1879,9 +1879,9 @@ void test_ge(void) {
|
|||
*
|
||||
* When the endomorphism code is compiled in, p5 = lambda*p1 and p6 = lambda^2*p1 are added as well.
|
||||
*/
|
||||
secp256k1_ge *ge = (secp256k1_ge *)malloc(sizeof(secp256k1_ge) * (1 + 4 * runs));
|
||||
secp256k1_gej *gej = (secp256k1_gej *)malloc(sizeof(secp256k1_gej) * (1 + 4 * runs));
|
||||
secp256k1_fe *zinv = (secp256k1_fe *)malloc(sizeof(secp256k1_fe) * (1 + 4 * runs));
|
||||
secp256k1_ge *ge = (secp256k1_ge *)checked_malloc(&ctx->error_callback, sizeof(secp256k1_ge) * (1 + 4 * runs));
|
||||
secp256k1_gej *gej = (secp256k1_gej *)checked_malloc(&ctx->error_callback, sizeof(secp256k1_gej) * (1 + 4 * runs));
|
||||
secp256k1_fe *zinv = (secp256k1_fe *)checked_malloc(&ctx->error_callback, sizeof(secp256k1_fe) * (1 + 4 * runs));
|
||||
secp256k1_fe zf;
|
||||
secp256k1_fe zfi2, zfi3;
|
||||
|
||||
|
@ -1919,7 +1919,7 @@ void test_ge(void) {
|
|||
|
||||
/* Compute z inverses. */
|
||||
{
|
||||
secp256k1_fe *zs = malloc(sizeof(secp256k1_fe) * (1 + 4 * runs));
|
||||
secp256k1_fe *zs = checked_malloc(&ctx->error_callback, sizeof(secp256k1_fe) * (1 + 4 * runs));
|
||||
for (i = 0; i < 4 * runs + 1; i++) {
|
||||
if (i == 0) {
|
||||
/* The point at infinity does not have a meaningful z inverse. Any should do. */
|
||||
|
@ -2020,7 +2020,7 @@ void test_ge(void) {
|
|||
/* Test adding all points together in random order equals infinity. */
|
||||
{
|
||||
secp256k1_gej sum = SECP256K1_GEJ_CONST_INFINITY;
|
||||
secp256k1_gej *gej_shuffled = (secp256k1_gej *)malloc((4 * runs + 1) * sizeof(secp256k1_gej));
|
||||
secp256k1_gej *gej_shuffled = (secp256k1_gej *)checked_malloc(&ctx->error_callback, (4 * runs + 1) * sizeof(secp256k1_gej));
|
||||
for (i = 0; i < 4 * runs + 1; i++) {
|
||||
gej_shuffled[i] = gej[i];
|
||||
}
|
||||
|
@ -2041,9 +2041,9 @@ void test_ge(void) {
|
|||
|
||||
/* Test batch gej -> ge conversion with and without known z ratios. */
|
||||
{
|
||||
secp256k1_fe *zr = (secp256k1_fe *)malloc((4 * runs + 1) * sizeof(secp256k1_fe));
|
||||
secp256k1_ge *ge_set_table = (secp256k1_ge *)malloc((4 * runs + 1) * sizeof(secp256k1_ge));
|
||||
secp256k1_ge *ge_set_all = (secp256k1_ge *)malloc((4 * runs + 1) * sizeof(secp256k1_ge));
|
||||
secp256k1_fe *zr = (secp256k1_fe *)checked_malloc(&ctx->error_callback, (4 * runs + 1) * sizeof(secp256k1_fe));
|
||||
secp256k1_ge *ge_set_table = (secp256k1_ge *)checked_malloc(&ctx->error_callback, (4 * runs + 1) * sizeof(secp256k1_ge));
|
||||
secp256k1_ge *ge_set_all = (secp256k1_ge *)checked_malloc(&ctx->error_callback, (4 * runs + 1) * sizeof(secp256k1_ge));
|
||||
for (i = 0; i < 4 * runs + 1; i++) {
|
||||
/* Compute gej[i + 1].z / gez[i].z (with gej[n].z taken to be 1). */
|
||||
if (i < 4 * runs) {
|
||||
|
|
Loading…
Reference in New Issue