diff --git a/leetcode/src/5.c b/leetcode/src/5.c index e54bf598da..4572a90dbb 100644 --- a/leetcode/src/5.c +++ b/leetcode/src/5.c @@ -42,7 +42,7 @@ char * longestPalindrome(char * s) { } } - if ((s_longest = (char *) malloc(sizeof(s))) == NULL) { + if ((s_longest = malloc((size_t)sz_max + 1)) == NULL) { return NULL; } strncpy(s_longest, s + si_max, sz_max);