Skip to content

Commit 11a9478

Browse files
committed
Fix crash in enline
demo'ed by this code: >> enline "^/a^/b" This fixes zsx#16
1 parent 44e09c5 commit 11a9478

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/s-ops.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,11 @@ static REBYTE seed_str[SEED_LEN] = {
458458
// Add missing CRs:
459459
while (cnt > 0) {
460460
bp[tail--] = bp[len]; // Copy src to dst.
461-
if (bp[len--] == LF && bp[len] != CR) {
461+
if (bp[len] == LF && (len == 0 || bp[len - 1] != CR)) {
462462
bp[tail--] = CR;
463463
cnt--;
464464
}
465+
len--;
465466
}
466467
}
467468

@@ -495,10 +496,11 @@ static REBYTE seed_str[SEED_LEN] = {
495496
// Add missing CRs:
496497
while (cnt > 0) {
497498
bp[tail--] = bp[len]; // Copy src to dst.
498-
if (bp[len--] == LF && bp[len] != CR) {
499+
if (bp[len] == LF && (len == 0 || bp[len] != CR)) {
499500
bp[tail--] = CR;
500501
cnt--;
501502
}
503+
len--;
502504
}
503505
}
504506

0 commit comments

Comments
 (0)