Skip to contentSkip to conversation

read-cache: use of memory after it is freed

PATCH In review Carlo Marcelo Arenas Belón 3 participants 3 messages Oct 20, 2018 – Oct 22, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 read-cache: use of memory after it is freed

introduced with c46c406ae1e (trace.h: support nested performance tracing) on Aug 18, 2018 but not affecting maint

---
 read-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
read-cache.c +1 -1
index 1df5c16dbc..78f47d2f50 100644
@@ -2297,8 +2297,8 @@ int read_index_from(struct index_state *istate, const char *path,
 	freshen_shared_index(base_path, 0);
 	merge_base_index(istate);
 	post_read_index_from(istate);
-	free(base_path);
 	trace_performance_leave("read cache %s", base_path);
+	free(base_path);
 	return ret;
 }
 
Signature · 1 line
2.19.1
#1 lore raw
Quoted 14 lines · Carlo Marcelo Arenas Belón

introduced with c46c406ae1e (trace.h: support nested performance tracing) on Aug 18, 2018 but not affecting maint

---
 read-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
read-cache.c +0 -0
index 1df5c16dbc..78f47d2f50 100644

read-cache.c int read_index_from(struct index_state *istate, const char *path, · line 2301

Quoted 6 lines
read-cache.c +1 -1
@@ -2297,8 +2297,8 @@ int read_index_from(struct index_state *istate, const char *path,
        freshen_shared_index(base_path, 0);
        merge_base_index(istate);
        post_read_index_from(istate);
-       free(base_path);
        trace_performance_leave("read cache %s", base_path);
+       free(base_path);

Oops. Ack.

Quoted 6 lines
read-cache.c +0 -1
        return ret;
 }
 
--

2.19.1

Signature · 1 line
Duy
#2 lore raw
Quoted 8 lines · Duy Nguyen

read-cache.c int read_index_from(struct index_state *istate, const char *path, · line 2301

Quoted 6 lines
        freshen_shared_index(base_path, 0);
        merge_base_index(istate);
        post_read_index_from(istate);
read-cache.c +1 -1
-       free(base_path);
        trace_performance_leave("read cache %s", base_path);
+       free(base_path);

Oops. Ack.

Thanks, both.

Quoted 2 lines
Quoted 2 lines

introduced with c46c406ae1e (trace.h: support nested performance tracing) on Aug 18, 2018 but not affecting maint

Yup. The series nd/unpack-trees-with-cache-tree however was designed to be merge-able down to 'maint', so it is a good idea to fix this at the tip of the topic. So I'll queue it on top of 5f4436a7 ("Document update for nd/unpack-trees-with-cache-tree", 2018-08-25).