summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/04_bugs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-05-30 15:49:18 +0200
committerJo-Philipp Wich <jo@mein.io>2022-05-30 16:02:13 +0200
commitda3f089e94203dd1e7c86f457d9faf4c2293d5d8 (patch)
tree79f8b047c2a5dd5b80097dbf2263bcc46774f46c /tests/custom/04_bugs
parent081871e18db544e2c834a516950e1c16c9bc4d2c (diff)
lib: rework uc_index() implementation
- Fix segfault on passing string haystack with non-string needle argument - Perform strict equality tests against array haystacks - Make string searches binary safe - Improve left index string search performance - Improve right index array search performance - Add missing test coverage for index() and rindex() Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/custom/04_bugs')
-rw-r--r--tests/custom/04_bugs/38_index_segfault28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/custom/04_bugs/38_index_segfault b/tests/custom/04_bugs/38_index_segfault
new file mode 100644
index 0000000..e29b99f
--- /dev/null
+++ b/tests/custom/04_bugs/38_index_segfault
@@ -0,0 +1,28 @@
+When index() or rindex() was invoked with a string haystack and a non-
+string needle argument, a segmentation fault occurred due to an internal
+strlen() invocation on a NULL pointer.
+
+-- Testcase --
+print(index("abc", []), "\n")
+-- End --
+
+-- Args --
+-R
+-- End --
+
+-- Expect stdout --
+-1
+-- End --
+
+
+-- Testcase --
+print(rindex("abc", []), "\n")
+-- End --
+
+-- Args --
+-R
+-- End --
+
+-- Expect stdout --
+-1
+-- End --