mirror of
https://gittea.dev/nova/th.git
synced 2025-10-26 04:34:34 -04:00
fixed missing 0 termination in smartcasestr
This commit is contained in:
@@ -9,7 +9,7 @@ char* concat(const char *s1, const char *s2){
|
|||||||
memcpy(result + len1, s2, len2 + 1);
|
memcpy(result + len1, s2, len2 + 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
char* smartstrcasestr(char *haystack, const char *needle){
|
char* smartstrcasestr(const char *haystack, const char *needle){
|
||||||
char smart = 0;
|
char smart = 0;
|
||||||
char *ret;
|
char *ret;
|
||||||
char passes = 0;
|
char passes = 0;
|
||||||
@@ -24,7 +24,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
|
|||||||
needle -= passes;
|
needle -= passes;
|
||||||
if (smart == 0) {
|
if (smart == 0) {
|
||||||
char *needle_case = malloc(strlen(needle)+1);
|
char *needle_case = malloc(strlen(needle)+1);
|
||||||
memcpy(needle_case, needle, strlen(needle));
|
memcpy(needle_case, needle, strlen(needle)+1);
|
||||||
passes = 0;
|
passes = 0;
|
||||||
while (*needle_case) {
|
while (*needle_case) {
|
||||||
*needle_case = *needle_case | ' ';
|
*needle_case = *needle_case | ' ';
|
||||||
@@ -34,7 +34,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
|
|||||||
needle_case -= passes;
|
needle_case -= passes;
|
||||||
|
|
||||||
char *haystack_case = malloc(strlen(haystack)+1);
|
char *haystack_case = malloc(strlen(haystack)+1);
|
||||||
memcpy(haystack_case, haystack, strlen(haystack));
|
memcpy(haystack_case, haystack, strlen(haystack)+1);
|
||||||
passes = 0;
|
passes = 0;
|
||||||
while (*haystack_case) {
|
while (*haystack_case) {
|
||||||
*haystack_case = *haystack_case | ' ';
|
*haystack_case = *haystack_case | ' ';
|
||||||
|
|||||||
Reference in New Issue
Block a user