commit b6c8e5e0edc57f309ae866114527e614ad0cd76d from: Stefan Sperling via: Thomas Adam date: Tue Oct 12 20:02:46 2021 UTC fix a segfault in edscript() introduced by my previous commit Found by our cherrypick regression tests. commit - 461f6aedbd48fa1a352a579c70013ff02d50a6c5 commit + b6c8e5e0edc57f309ae866114527e614ad0cd76d blob - cdb83d926a830340f0bdbf339072f2e5f816d3be blob + 899e70b054294423e8273fb0e275949925cc8909 --- lib/diff3.c +++ lib/diff3.c @@ -981,7 +981,7 @@ edscript(int n, struct diff3_state *d3s) off_t len; char *line = NULL; size_t linesize = 0; - ssize_t linelen, k; + ssize_t linelen = 0, k; for (; n > 0; n--) { if (!d3s->overlap[n]) { @@ -1012,7 +1012,7 @@ edscript(int n, struct diff3_state *d3s) goto done; } err = diff_output(d3s->diffbuf, "%s%s\n", - line[linelen] == '\n' ? ":" : "", + linelen > 0 && line[linelen] == '\n' ? ":" : "", GOT_DIFF_CONFLICT_MARKER_SEP); if (err) goto done;