Thread (92 messages) 92 messages, 5 authors, 2022-02-04

Re: [PATCH v8 5/6] branch: add --recurse-submodules option for branch creation

flat view

From: Glen Choo <hidden>
Date: 2022-02-04 01:10:34
Subsystem: the rest · Maintainer: Linus Torvalds

I tested this series some more and found a silly bug.
Let me know if I should just send v9 instead.

----- >8 --------- >8 --------- >8 --------- >8 --------- >8 ----

Subject: [PATCH] submodule-config.c: remove accidental pointer reuse

List entries allocated by traverse_tree_submodules() are sharing the
.name_entry pointer, but each of them needs their own pointer. Fix this.

Signed-off-by: Glen Choo <redacted>
---
 submodule-config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/submodule-config.c b/submodule-config.c
index 24b8d1a700..c9f54bc72d 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -757,7 +757,8 @@ static void traverse_tree_submodules(struct repository *r,
 		if (S_ISGITLINK(name_entry->mode) &&
 		    is_tree_submodule_active(r, root_tree, tree_path)) {
 			st_entry = xmalloc(sizeof(*st_entry));
-			st_entry->name_entry = name_entry;
+			st_entry->name_entry = xmalloc(sizeof(*st_entry->name_entry));
+			*st_entry->name_entry = *name_entry;
 			st_entry->submodule =
 				submodule_from_path(r, root_tree, tree_path);
 			st_entry->repo = xmalloc(sizeof(*st_entry->repo));
-- 
2.35.0.263.gb82422642f-goog
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help