Thread (1 message) 1 message, 1 author, 2023-06-14
DORMANTno replies

[PATCH] notes: do not access before the beginning of an array

From: Junio C Hamano <hidden>
Date: 2023-06-14 01:10:53
Subsystem: the rest · Maintainer: Linus Torvalds

The check to see if the last byte of the separator string is a LF
makes sense *only* when the separator string is known to be non
empty.  This has been breaking the asan/ubsan job at CI.

Signed-off-by: Junio C Hamano <redacted>
---
 * This time with a proposed log message with sign-off.

 builtin/notes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index 6eede30597..785b1922ad 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -239,7 +239,7 @@ static void write_note_data(struct note_data *d, struct object_id *oid)
 
 static void append_separator(struct strbuf *message)
 {
-	if (separator[strlen(separator) - 1] == '\n')
+	if (*separator && separator[strlen(separator) - 1] == '\n')
 		strbuf_addstr(message, separator);
 	else
 		strbuf_addf(message, "%s%s", separator, "\n");
-- 
2.41.0-28-gd7d8841f67
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help