From 7cc0d624bef892000b8c4f81c0a54733f29eda0a Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 23 Sep 2024 15:10:39 +0900 Subject: [PATCH] Fix use-after-free in path-to-filename function --- src/html_cache.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/html_cache.c b/src/html_cache.c index cbf5f17..f851c09 100644 --- a/src/html_cache.c +++ b/src/html_cache.c @@ -77,7 +77,10 @@ char *c_simple_http_path_to_cache_filename(const char *path) { } if (prev_idx == 0) { - return stripped_path; + // Prevent string from being free'd by moving it to another variable. + char *temp = stripped_path; + stripped_path = NULL; + return temp; } else { return c_simple_http_combine_string_parts(parts); }