From e059daa0f16f73f27dbdb232ede037d1a43f1fee Mon Sep 17 00:00:00 2001 From: Petr <30545094+pasabanov@users.noreply.github.com> Date: Mon, 15 Jul 2024 09:34:08 +0300 Subject: Optimize performance of ndpi_strnstr() and possible bugfix (#2494) --- example/ndpiReader.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'example') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index dd908e5ce..65246c05c 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -5782,6 +5782,13 @@ void strnstrUnitTest(void) { /* Test 13 */ assert(ndpi_strnstr("abcdef", "abc", 2) == NULL); + + /* Test 14: zero length */ + assert(strcmp(ndpi_strnstr("", "", 0), "") == 0); + assert(strcmp(ndpi_strnstr("string", "", 0), "string") == 0); + assert(ndpi_strnstr("", "str", 0) == NULL); + assert(ndpi_strnstr("string", "str", 0) == NULL); + assert(ndpi_strnstr("str", "string", 0) == NULL); } /* *********************************************** */ -- cgit v1.2.3