cdef int init_c_vector_modint(c_vector_modint* v, int p, Py_ssize_t degree,
Py_ssize_t num_nonzero) except -1:
"""
Initialize a c_vector_modint.
"""
if (allocate_c_vector_modint(v, num_nonzero) == -1):
raise MemoryError, "Error allocating memory for sparse vector."
if p > 46340:
raise OverflowError, "The prime must be <= 46340."
v.num_nonzero = num_nonzero
v.degree = degree
v.p = p
return 0
On OverflowError v is leaked. Switching check and allocation will fix the problem.