Skip to content

Commit d922a37

Browse files
committed
fixup??? built-in add -i: implement the main loop
Whoops, a buffer overrun. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e80cb79 commit d922a37

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

add-interactive.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ static ssize_t list_and_choose(struct add_i_state *s,
351351
}
352352
}
353353

354-
p[sep] = '\0';
354+
if (p[sep])
355+
p[sep++] = '\0';
355356
if (from < 0) {
356357
from = find_unique(p, items);
357358
if (from >= 0)
@@ -377,7 +378,7 @@ static ssize_t list_and_choose(struct add_i_state *s,
377378
res += choose ? +1 : -1;
378379
}
379380

380-
p += sep + 1;
381+
p += sep;
381382
}
382383

383384
if ((immediate && res != LIST_AND_CHOOSE_ERROR) ||

0 commit comments

Comments
 (0)