Thread (1 message) 1 message, 1 author, 2022-08-16

Re: [PATCH v8] submodule merge: update conflict error message

From: Junio C Hamano <hidden>
Date: 2022-08-16 19:39:56
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Calvin Wan [off-list ref] writes:
On Tue, Aug 16, 2022 at 11:58 AM Junio C Hamano [off-list ref] wrote:
quoted
Junio C Hamano [off-list ref] writes:
quoted
quoted
+                     * languages, the following swap is suggested:
+                     *      "   %s\n" -> "%s   \n"
+                     */
+                    strbuf_addf(&tmp, _("   %s\n"), msg_list.items[i].string);
+    }
+    strbuf_reset(msg);
+    strbuf_add(msg, tmp.buf, tmp.len);
+}
Here, tmp is not released, and mst_list holds the words split out of msg.
FWIW, with this fixed, the tip of 'seen' passes the linux-leaks CI
job.
quoted
 merge-ort.c | 2 ++
 1 file changed, 2 insertions(+)
...
Should I re-roll with just that change?
I think the topic is already in 'next', so no, it is too late for
that.

I queued the attached on top but haven't merged to 'next' yet.
Making sure that there is no silly mistakes (like "oh, no, that
temporary variable is still alive and it shouldn't be released there
just yet") by lending an extra pair of eyes is what is the most
useful at this point ;-)
--- >8 ---
Subject: [PATCH] merge-ort: plug leaks in "submodule conflict suggestion" code

The helper function uses two temporary variables that it forgets to
release after it is done with them.

Signed-off-by: Junio C Hamano <redacted>
---
 merge-ort.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/merge-ort.c b/merge-ort.c
index a52faf6e21..f33df3ff65 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4507,6 +4507,8 @@ static void format_submodule_conflict_suggestion(struct strbuf *msg) {
 	}
 	strbuf_reset(msg);
 	strbuf_add(msg, tmp.buf, tmp.len);
+	string_list_clear(&msg_list, 0);
+	strbuf_release(&tmp);
 }
 
 static void print_submodule_conflict_suggestion(struct string_list *csub) {
-- 
2.37.2-492-g20f88697f3

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help