595@@ -596,14 +596,15 @@ static int secp256k1_ecmult_strauss_batch(const secp256k1_callback* error_callba
596 state.prej = (secp256k1_gej*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_gej));
597 state.zr = (secp256k1_fe*)secp256k1_scratch_alloc(error_callback, scratch, n_points * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_fe));
598 state.pre_a = (secp256k1_ge*)secp256k1_scratch_alloc(error_callback, scratch, n_points * 2 * ECMULT_TABLE_SIZE(WINDOW_A) * sizeof(secp256k1_ge));
599- state.pre_a_lam = state.pre_a + n_points * ECMULT_TABLE_SIZE(WINDOW_A);
600 state.ps = (struct secp256k1_strauss_point_state*)secp256k1_scratch_alloc(error_callback, scratch, n_points * sizeof(struct secp256k1_strauss_point_state));
601
602- if (points == NULL || scalars == NULL || state.prej == NULL || state.zr == NULL || state.pre_a == NULL) {
603+ if (points == NULL || scalars == NULL || state.prej == NULL || state.zr == NULL || state.pre_a == NULL || state.ps == NULL) {
Crazy that we missed this in #600.
nit:
Maybe it will be better to call secp256k1_scratch_alloc
also for state.pre_a_lam
. This will be more consistent. I think the current code was good when we still had the endo ifdefs but it’s no longer natural now that we removed these. But I don’t have strong opinions on this. The version after the PR here is correct but invites doing NULL pointer arithmetic..