From d5cc5d9339d09676f365a695337ed98ffdb74b64 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 22 Mar 2024 18:17:15 -0400 Subject: Bugfix in split() * On error sptr is not longer indirectly free'd. --- src/str.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/str.c b/src/str.c index 15fbcde..a6a848c 100644 --- a/src/str.c +++ b/src/str.c @@ -187,7 +187,6 @@ char** split(char *_sptr, const char* delim, size_t max) // Duplicate the input string and save a copy of the pointer to be freed later char *orig = _sptr; char *sptr = strdup(orig); - char *sptr_begin = sptr; if (!sptr) { return NULL; @@ -226,7 +225,6 @@ char** split(char *_sptr, const char* delim, size_t max) break; } else { if (!result[i]) { - guard_free(sptr_begin); return NULL; } strcpy(result[i], token); @@ -235,8 +233,6 @@ char** split(char *_sptr, const char* delim, size_t max) --x; //memcpy(result[i], token, strlen(token) + 1); // copy the string contents into the record } - guard_free(sptr_begin); - sptr_begin = NULL; sptr = NULL; return result; } -- cgit