Skip to content

Commit

Permalink
pperm: fix bug in PreImagePPermInt
Browse files Browse the repository at this point in the history
This occasionally caused incorrect values to be returned when i == deg
and by coincidence ptf2[i] == cpt. When ptf2[deg] is beyond the end of
the bag containing f, and so is not valid. For reference, this bug
caused errors in:

semigroups/Semigroups#296
semigroups/Semigroups#472
  • Loading branch information
James Mitchell committed Apr 5, 2018
1 parent 37aee87 commit c6174ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pperm.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ static Obj PreImagePPermInt(Obj pt, Obj f)
deg = DEG_PPERM2(f);
while (ptf2[i] != cpt && i < deg)
i++;
if (ptf2[i] != cpt)
if (i == deg || ptf2[i] != cpt)

This comment has been minimized.

Copy link
@fingolfin

fingolfin Apr 5, 2018

Member

Hmm, so the loop above still contains an OOB access - make i < deg come first?

return Fail;
}
else {
ptf4 = ADDR_PPERM4(f);
deg = DEG_PPERM4(f);
while (ptf4[i] != cpt && i < deg)
i++;
if (ptf4[i] != cpt)
if (i == deg || ptf4[i] != cpt)
return Fail;
}
return INTOBJ_INT(i + 1);
Expand Down

0 comments on commit c6174ff

Please sign in to comment.