Browse code

core: ut - fixed str_casesearch() - fixed str_casesearch() behaviour on text and needle were equal

(cherry picked from commit c146ef490e1d7d35add7d3ee593f6d3d20e327ad)

Boris Korzun authored on 25/05/2021 14:00:19 • Daniel-Constantin Mierla committed on 26/05/2021 06:14:42
Showing 1 changed files
... ...
@@ -327,7 +327,7 @@ char *stre_search_strz(char *vstart, char *vend, char *needlez)
327 327
 char *str_casesearch(str *text, str *needle)
328 328
 {
329 329
 	int i,j;
330
-	for(i=0;i<text->len-needle->len;i++) {
330
+	for(i=0;i<=text->len-needle->len;i++) {
331 331
 		for(j=0;j<needle->len;j++) {
332 332
 			if ( !((text->s[i+j]==needle->s[j]) ||
333 333
 					( isalpha((int)text->s[i+j])
... ...
@@ -337,7 +337,7 @@ char *str_casesearch(str *text, str *needle)
337 337
 		if (j==needle->len)
338 338
 			return text->s+i;
339 339
 	}
340
-	return 0;
340
+	return NULL;
341 341
 }
342 342
 
343 343
 /**