Skip to content

Commit

Permalink
Fix bug caused by garbage collection
Browse files Browse the repository at this point in the history
AInvInt can cause a garbage collection, which moves the memory that
ptKnown points to.
  • Loading branch information
ChrisJefferson authored and fingolfin committed Mar 28, 2018
1 parent ad6d758 commit 89a3595
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/permutat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ Obj PowPerm2Int (

/* compute the power by raising the cycles individually for large exps */
else if ( TNUM_OBJ(opR) == T_INTNEG ) {
/* do negation first as it can cause a garbage collection */
opR = AInvInt(opR);

/* make sure that the buffer bag is large enough */
UseTmpPerm(SIZE_OBJ(opL));
Expand All @@ -1145,7 +1147,6 @@ Obj PowPerm2Int (
ptKnown[p] = 0;

/* get pointer to the permutation and the power */
opR = AInvInt(opR);
ptL = CONST_ADDR_PERM2(opL);
ptP = ADDR_PERM2(pow);

Expand Down Expand Up @@ -1397,6 +1398,8 @@ Obj PowPerm4Int (

/* compute the power by raising the cycles individually for large exps */
else if ( TNUM_OBJ(opR) == T_INTNEG ) {
/* do negation first as it can cause a garbage collection */
opR = AInvInt(opR);

/* make sure that the buffer bag is large enough */
UseTmpPerm(SIZE_OBJ(opL));
Expand All @@ -1407,7 +1410,6 @@ Obj PowPerm4Int (
ptKnown[p] = 0;

/* get pointer to the permutation and the power */
opR = AInvInt(opR);
ptL = CONST_ADDR_PERM4(opL);
ptP = ADDR_PERM4(pow);

Expand Down

0 comments on commit 89a3595

Please sign in to comment.