[glib/wip/smcv/2452-g-string-0-length-replace: 5/5] test_string_replace: Exercise zero-length replacements
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/smcv/2452-g-string-0-length-replace: 5/5] test_string_replace: Exercise zero-length replacements
- Date: Mon, 2 Aug 2021 11:02:22 +0000 (UTC)
commit 0138dc81220e8503895bb2c1390ef1cd12a5a0fd
Author: Simon McVittie <smcv collabora com>
Date: Mon Aug 2 11:52:58 2021 +0100
test_string_replace: Exercise zero-length replacements
Previously, these would have done 2**32 replacements, and the first one
would have consumed 6GB of memory in the process. They now match what
Python `str.replace()` does.
Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2452
Signed-off-by: Simon McVittie <smcv collabora com>
glib/tests/string.c | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/glib/tests/string.c b/glib/tests/string.c
index de02f73ec..5f1b7578e 100644
--- a/glib/tests/string.c
+++ b/glib/tests/string.c
@@ -528,6 +528,12 @@ test_string_replace (void)
"", 3 },
{ "aaa", "aa", "bb", 0,
"bba", 1 },
+ { "foo", "", "bar", 0,
+ "barfbarobarobar", 4 },
+ { "", "", "x", 0,
+ "x", 1 },
+ { "", "", "", 0,
+ "", 1 },
};
guint i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]