From 558874c1a8e34bd4a28bdc331f0a3b21dcf2c75a Mon Sep 17 00:00:00 2001 From: Markus Pfeiffer Date: Fri, 8 Apr 2016 16:13:25 +0100 Subject: [PATCH] Fix #717 `OnTuplesPerm` left negative integers invariant instead of giving an error, which would be consistent with the manual. --- src/permutat.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/permutat.c b/src/permutat.c index bcc6b7f126..069d48567e 100644 --- a/src/permutat.c +++ b/src/permutat.c @@ -4112,6 +4112,7 @@ Obj OnTuplesPerm ( UInt lmp; /* largest moved point */ UInt i, k; /* loop variables */ + tmp = NULL; /* stop compiler from complaining */ /* make a bag for the result and initialize pointers */ res = NEW_PLIST( IS_MUTABLE_PLIST(tup) ? T_PLIST : T_PLIST + IMMUTABLE, LEN_LIST(tup) ); @@ -4128,11 +4129,11 @@ Obj OnTuplesPerm ( /* loop over the entries of the tuple */ for ( i = LEN_LIST(tup); 1 <= i; i--, ptTup--, ptRes-- ) { - if (IS_INTOBJ(*ptTup)) { + if (IS_INTOBJ(*ptTup) && (0 < INT_INTOBJ(*ptTup))) { k = INT_INTOBJ( *ptTup ); - if ( k <= 0 || k > lmp ) + if (k > lmp) { tmp = *ptTup; - else + } else tmp = INTOBJ_INT( ptPrm2[k-1] + 1 ); *ptRes = tmp; } @@ -4163,11 +4164,11 @@ Obj OnTuplesPerm ( /* loop over the entries of the tuple */ for ( i = LEN_LIST(tup); 1 <= i; i--, ptTup--, ptRes-- ) { - if (IS_INTOBJ(*ptTup)) { + if (IS_INTOBJ(*ptTup) && (0 < INT_INTOBJ(*ptTup))) { k = INT_INTOBJ( *ptTup ); - if ( k <= 0 || k > lmp ) + if (k > lmp) { tmp = *ptTup; - else + } else tmp = INTOBJ_INT( ptPrm4[k-1] + 1 ); *ptRes = tmp; }