Currently if secp256k1_gej_add_var
/ secp256k1_gej_add_ge_var
/ secp256k1_gej_add_zinv_var
receive P + (-P)
it will set gej->infinity = 1
but doesn’t call initialize the field elements.
Notice that this is the only branch in the function that results in an uninitialized output.
By using secp256k1_gej_set_infinity()
it will set the field elements to zero while also setting the infinity flag.
I also added a test that fails with valgrind on current master but passes with the fix.
EDIT: This isn’t a bug or something necessary, I just personally found this helpful.