Skip to content

Commit 3ebd8ff

Browse files
committed
Prevent flint clear of null pointer
1 parent aef740c commit 3ebd8ff

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/flint/types/fmpq_vec.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ cdef class fmpq_vec:
3131

3232
def __dealloc__(self):
3333
libc.stdlib.free(self.double_indirect)
34-
_fmpq_vec_clear(self.val, self.length)
34+
if self.val is not NULL:
35+
_fmpq_vec_clear(self.val, self.length)
36+
self.val = NULL
3537

3638
def __getitem__(self, x):
3739
if not isinstance(x, int):

src/flint/types/fmpz_vec.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ cdef class fmpz_vec:
3232

3333
def __dealloc__(self):
3434
libc.stdlib.free(self.double_indirect)
35-
_fmpz_vec_clear(self.val, self.length)
35+
if self.val is not NULL:
36+
_fmpz_vec_clear(self.val, self.length)
37+
self.val = NULL
3638

3739
def __getitem__(self, x):
3840
if not isinstance(x, int):

0 commit comments

Comments
 (0)