From 4229ebe1d5a5f796eaaf6cb8581491878f9ff110 Mon Sep 17 00:00:00 2001 From: nova Date: Fri, 24 Oct 2025 20:03:55 +0200 Subject: [PATCH] fixed missing 0 termination in smartcasestr --- backend.c | 6 +++--- backend.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend.c b/backend.c index 26b01c4..317bc64 100644 --- a/backend.c +++ b/backend.c @@ -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 | ' '; diff --git a/backend.h b/backend.h index bbf0919..08fa404 100644 --- a/backend.h +++ b/backend.h @@ -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);