Mercurial > hg > xemacs-beta
changeset 5886:c96000075e49
Be more careful about C integer overflow, #'parse-integer.
src/ChangeLog addition:
2015-04-08 Aidan Kehoe <kehoea@parhasard.net>
* data.c (parse_integer):
Fix a bug in my detecting a C overflow here.
tests/ChangeLog addition:
2015-04-08 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Add a couple of tests for #'parse-integer to check for a bug just
fixed.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 08 Apr 2015 21:03:18 +0100 |
parents | c8bbb32fe124 |
children | 6eca500211f4 |
files | src/ChangeLog src/data.c tests/ChangeLog tests/automated/lisp-tests.el |
diffstat | 4 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Sat Apr 04 13:49:30 2015 +0100 +++ b/src/ChangeLog Wed Apr 08 21:03:18 2015 +0100 @@ -1,3 +1,8 @@ +2015-04-08 Aidan Kehoe <kehoea@parhasard.net> + + * data.c (parse_integer): + Fix a bug in my detecting a C overflow here. + 2015-04-01 Aidan Kehoe <kehoea@parhasard.net> * process.c (Fgetenv):
--- a/src/data.c Sat Apr 04 13:49:30 2015 +0100 +++ b/src/data.c Wed Apr 08 21:03:18 2015 +0100 @@ -1780,7 +1780,7 @@ onum = num; num *= base; - if (num > fixnum_limit) + if (num > fixnum_limit || num < onum) { goto overflow; }
--- a/tests/ChangeLog Sat Apr 04 13:49:30 2015 +0100 +++ b/tests/ChangeLog Wed Apr 08 21:03:18 2015 +0100 @@ -1,3 +1,9 @@ +2015-04-08 Aidan Kehoe <kehoea@parhasard.net> + + * automated/lisp-tests.el: + Add a couple of tests for #'parse-integer to check for a bug just + fixed. + 2015-03-16 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el:
--- a/tests/automated/lisp-tests.el Sat Apr 04 13:49:30 2015 +0100 +++ b/tests/automated/lisp-tests.el Wed Apr 08 21:03:18 2015 +0100 @@ -3606,6 +3606,14 @@ (Assert (equal (multiple-value-list (parse-integer "abc" :junk-allowed t)) '(nil 0))) + (Assert (eql (ignore-errors (parse-integer "100000000" + :radix 16)) + (if (featurep 'bignum) (lsh 1 32) nil)) + "checking an overflow bug has been fixed") + (Assert (eql (ignore-errors (parse-integer "-100000000" + :radix 16)) + (if (featurep 'bignum) (- (lsh 1 32) nil)) + "checking an overflow bug has been fixed, negative int") (Check-Error invalid-argument (parse-integer "0123456789" :radix 8)) (Check-Error invalid-argument (parse-integer "abc"))