diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-08-07 23:56:19 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-08-07 23:56:19 -0400 |
| commit | 5348faebaab97373d758588bc89d13ea80c314f7 (patch) | |
| tree | d5e3dcc5ca079aa9b68435cf3f03c511047e7708 /src | |
| parent | 360d6271e1a20d128430e52637d5d35f4c706ca5 (diff) | |
| download | beaker-5348faebaab97373d758588bc89d13ea80c314f7.tar.gz | |
fix: remove redundant cookie header copy
Diffstat (limited to 'src')
| -rw-r--r-- | src/http.c | 20 |
1 files changed, 5 insertions, 15 deletions
@@ -180,18 +180,10 @@ char *get_cookie(const char *cookie_name) { strncpy(cookie_str, cookie_header_start, cookie_str_len); cookie_str[cookie_str_len] = '\0'; - char *cookie_str_copy = strdup(cookie_str); - if (cookie_str_copy == NULL) { - perror("Failed to duplicate cookie string for strtok_r"); - fprintf(stderr, "[ERROR] get_cookie: Duplication failed for cookie_str_copy.\n"); - free(cookie_str); - return NULL; - } - char *token; char *saveptr_cookie; - token = strtok_r(cookie_str_copy, ";", &saveptr_cookie); + token = strtok_r(cookie_str, ";", &saveptr_cookie); while (token != NULL) { while (*token == ' ') { @@ -210,16 +202,14 @@ char *get_cookie(const char *cookie_name) { perror("Failed to duplicate cookie value"); fprintf(stderr, "[ERROR] get_cookie: Allocation failed for cookie_value.\n"); } - free(cookie_str); - free(cookie_str_copy); - return cookie_value; + free(cookie_str); + return cookie_value; } } token = strtok_r(NULL, ";", &saveptr_cookie); } - free(cookie_str); - free(cookie_str_copy); + free(cookie_str); return NULL; -}
\ No newline at end of file +} |
