Skip to content

Commit fa1216c

Browse files
author
Jonathan Kliem
committed
do not assign clones to objects on the pari stack
1 parent e2c9824 commit fa1216c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cypari2/gen.pyx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,11 @@ cdef class Gen(Gen_base):
15311531

15321532
self.cache((i,j), x)
15331533
xt = x.ref_target()
1534+
1535+
if not is_universal_constant(x.g):
1536+
# Make sure that self is on the heap, before we assign a clone to it.
1537+
self.fixGEN()
1538+
15341539
set_gcoeff(self.g, i+1, j+1, xt)
15351540
return
15361541

@@ -1555,6 +1560,10 @@ cdef class Gen(Gen_base):
15551560

15561561
self.cache(i, x)
15571562
xt = x.ref_target()
1563+
if not is_universal_constant(x.g):
1564+
# Make sure that self is on the heap, before we assign a clone to it.
1565+
self.fixGEN()
1566+
15581567
if typ(self.g) == t_LIST:
15591568
listput(self.g, xt, i+1)
15601569
else:

cypari2/pari_instance.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,10 @@ cdef class Pari(Pari_auto):
12981298
if len(entries) != m * n:
12991299
raise IndexError("len of entries (=%s) must be %s*%s=%s"%(len(entries),m,n,m*n))
13001300
k = 0
1301+
1302+
# Make sure that A is on the heap, before we assign clones to it.
1303+
A.fixGEN()
1304+
13011305
for i in range(m):
13021306
for j in range(n):
13031307
sig_check()
@@ -1318,7 +1322,7 @@ cdef class Pari(Pari_auto):
13181322
13191323
If the second argument `p` is specified, it must be a prime.
13201324
Then only the local information at `p` is computed and returned.
1321-
1325+
13221326
Examples:
13231327
13241328
>>> import cypari2

0 commit comments

Comments
 (0)