-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Fix: The error checking in PartialPerm has been corrected such that invalid inputs (numbers < 1) are detected #3944
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
if IsSSortedList(arg[1]) and ForAll(arg[1], IsSmallIntRep) | ||
and IsDuplicateFreeList(arg[2]) and ForAll(arg[2], IsSmallIntRep) | ||
if IsSSortedList(arg[1]) and ForAll(arg[1], IsPosInt and IsSmallIntRep) | ||
and IsDuplicateFreeList(arg[2]) and ForAll(arg[2], IsPosInt and IsSmallIntRep) | ||
and Length(arg[1]) = Length(arg[2]) then | ||
return SparsePartialPermNC(arg[1], arg[2]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking I'd feel better if we improved the input validation in SparsePartialPermNC
instead or in addition to the above, but as this PR fixes the immediate issue, I'd be happy to see it merged as-is, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The small pos int
and "sorted list" tests can be done very cheaply in the kernel; duplicate free might be more work, though perhaps even that could be done as a side effect of the kernel code. Anyway, as long as there is no performance issue here... shrug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree porting this all into the kernel might be netter, most of this comes almost for free while you are building the partial permutation (except DuplicateFreeList), but that would be a bigger change, and this little fix feels better for backporting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Backported to stable-4.11 in aac1175 |
Fixes #3943 , corruption caused by invalid inputs (numbers < 1) to PartialPerm