:: commit d22b97cf66ef8f61a5e115cdfc6ec01b10263e37

mintsuki <mintsuki@protonmail.com> — 2023-02-15 20:05

parents: 08b349e513

uri: Prevent memory leak when opening compressed files

diff --git a/common/lib/uri.c b/common/lib/uri.c
index 979595c3..80b24bf6 100644
--- a/common/lib/uri.c
+++ b/common/lib/uri.c
@@ -282,8 +282,9 @@ struct file_handle *uri_open(char *uri) {
         compressed_fd->path = ext_mem_alloc(ret->path_len);
         memcpy(compressed_fd->path, ret->path, ret->path_len);
         compressed_fd->path_len = ret->path_len;
-        fclose(ret);
         compressed_fd->is_memfile = true;
+        fclose(ret);
+        pmm_free(src, ret->size);
         ret = compressed_fd;
     }
 
tab: 248 wrap: offon