diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-08-24 06:28:39 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-08-24 06:28:39 -0700 |
commit | 3270a9ec78b00feb885b65915d020e60dd712a58 (patch) | |
tree | c91add01130f5109c6a0859f9f2dfb33fb13c21e | |
parent | a150a76a6b2944f1415fb42281bf3d6eecfece48 (diff) | |
download | txr-3270a9ec78b00feb885b65915d020e60dd712a58.tar.gz txr-3270a9ec78b00feb885b65915d020e60dd712a58.tar.bz2 txr-3270a9ec78b00feb885b65915d020e60dd712a58.zip |
bugfix: replace_str uses string_extend incorrectly.
One test case for this is that (append "ABC" "DEF")
returns an "ABCDEF" string whose length reports as 9
instead of the correct 6. This will wreak various havoc.
The bug was introduced in the very first version of
replace_str, in commit d011fda9b6b078f09027eb65d500c8beffc99414
on January 26, 2012.
In the same commit, the string_extend behavior is
introduced of supporting an integer value specifying the
number of characters by which to extend the string.
This feature of string_extend is used in replace_str,
but wrongly.
* lib.c (replace_str): Pass just the size delta
to string_extend; do not add the old length to the
delta such that the total size is wrongly passed.
-rw-r--r-- | lib.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -3936,7 +3936,7 @@ val replace_str(val str_in, val items, val from, val to) cnum t = c_num(to); cnum l = c_num(len); - string_extend(str_in, plus(len, len_diff)); + string_extend(str_in, len_diff); wmemmove(str_in->st.str + t + c_num(len_diff), str_in->st.str + t, (l - t) + 1); to = plus(from, len_it); |