1
0
mirror of https://gittea.dev/nova/th.git synced 2025-10-25 04:10:15 -04:00

fixed missing 0 termination in smartcasestr

This commit is contained in:
nova
2025-10-24 20:03:55 +02:00
parent 3da05ce27f
commit 4229ebe1d5
2 changed files with 4 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ char* concat(const char *s1, const char *s2){
memcpy(result + len1, s2, len2 + 1);
return result;
}
char* smartstrcasestr(char *haystack, const char *needle){
char* smartstrcasestr(const char *haystack, const char *needle){
char smart = 0;
char *ret;
char passes = 0;
@@ -24,7 +24,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
needle -= passes;
if (smart == 0) {
char *needle_case = malloc(strlen(needle)+1);
memcpy(needle_case, needle, strlen(needle));
memcpy(needle_case, needle, strlen(needle)+1);
passes = 0;
while (*needle_case) {
*needle_case = *needle_case | ' ';
@@ -34,7 +34,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
needle_case -= passes;
char *haystack_case = malloc(strlen(haystack)+1);
memcpy(haystack_case, haystack, strlen(haystack));
memcpy(haystack_case, haystack, strlen(haystack)+1);
passes = 0;
while (*haystack_case) {
*haystack_case = *haystack_case | ' ';

View File

@@ -6,4 +6,4 @@
char* concat(const char *s1, const char *s2);
char* smartstrcasestr(char *haystack, const char *needle);
char* smartstrcasestr(const char *haystack, const char *needle);