diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-05-31 19:00:36 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-05-31 19:00:36 -0700 |
commit | 59863eeb3e6d00c782063866d899a35f83b07ea5 (patch) | |
tree | d2b5691d736ce190732635a3d4267e9edf02d5f6 /lib.c | |
parent | 39c8698842bc132cbc2f44aadb83f12efc3aa062 (diff) | |
download | txr-59863eeb3e6d00c782063866d899a35f83b07ea5.tar.gz txr-59863eeb3e6d00c782063866d899a35f83b07ea5.tar.bz2 txr-59863eeb3e6d00c782063866d899a35f83b07ea5.zip |
bugfix: list length: off-by-one error huge lists.
* lib.c (length_list, length_proper_list): Fix off-by-one bug
when calculating lengths of lists that overflow the cnum type.
Note that we will never see regular lists which hit this
situation, because there are more values in the range [0,
INT_PTR_MAX] then there are possible pointers in the system,
However, lazy lists can be that long or longer, because as we
calculate the length of a lazy list, the part we have already
traversed can be garbage-collected under the right
circumstances.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -3127,6 +3127,7 @@ val length_list(val list) if (len < INT_PTR_MAX) return num(len); + list = cdr(list); bn_len = num(INT_PTR_MAX); while (consp(list)) { @@ -3152,6 +3153,7 @@ static val length_proper_list(val list) if (len < INT_PTR_MAX) return num(len); + list = cdr(list); bn_len = num(INT_PTR_MAX); while (list) { |