"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Fix another edscript() segfault
To:
gameoftrees@openbsd.org
Date:
Sat, 16 Oct 2021 15:27:00 +0200

Download raw body.

Thread
fix another segfault in edscript()

Same problem as fixed in 90de04bc7f1b, but a few lines further down.
Found by a random segfault while running regress.

==== update ====
./update.sh -q -r "/tmp"
Segmentation fault (core dumped)

Core was generated by `got'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000d506bae148 in edscript (n=1, d3s=0xd747ea7380)
    at ../lib/diff3.c:1051
1051                                line[linelen] == '\n' ? ":" : "",

diff 2e3a6c3be72d70d3e58780d82d7545cd0a3d9e82 /home/naddy/got
blob - 9b918583a6db04e4fff29bcb04a7490e23db43cc
file + lib/diff3.c
--- lib/diff3.c
+++ lib/diff3.c
@@ -1048,7 +1048,7 @@ edscript(int n, struct diff3_state *d3s)
 				goto done;
 		} else {
 			err = diff_output(d3s->diffbuf, "%s%s\n.\n",
-			    line[linelen] == '\n' ? ":" : "",
+			    linelen > 0 && line[linelen] == '\n' ? ":" : "",
 			    d3s->f3mark);
 			if (err)
 				goto done;
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de