]> git.seodisparate.com - c_simple_http/commitdiff
Fix use-after-free in path-to-filename function
authorStephen Seo <seo.disparate@gmail.com>
Mon, 23 Sep 2024 06:10:39 +0000 (15:10 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 23 Sep 2024 06:10:39 +0000 (15:10 +0900)
src/html_cache.c

index cbf5f1751edf21e091d395981a59f2c5b7a775cf..f851c09162fcfd3f5d22c53a32d27323cd55f8c7 100644 (file)
@@ -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);
   }