bwipe!
endfunc
+" Corrupted undo file via cyclic cross-references caused
+" double free
+func Test_corrupted_undofile()
+ CheckFeature persistent_undo
+ let _uf = &undofile
+ set undofile
+ new
+ call setline(1, 'hello')
+ let b=eval('0z56696D9F556E446FE50002F3AEFE62965A91903610' ..
+ \ 'F0E23CC8A69D5B87CEA6D28E75489B0D2CA02ED7993C' ..
+ \ '00000001000000000000000000000000000000010000' ..
+ \ '00010000000100000001000000010000000100000000' ..
+ \ '3B9ACA00005FD0000000010000000000000000000000' ..
+ \ '00000000010000000100000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '00000000000000000000000000000000000000000000' ..
+ \ '000000000000000000000000000000000000003B9ACA' ..
+ \ '00003581E7AA')
+ call writefile(b, 'Xundo', 'bD')
+ rundo Xundo
+ bw!
+ let &undofile = _uf
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
corruption_error("duplicate uh_seq", file_name);
goto error;
}
- for (j = 0; j < num_head; j++)
- if (uhp_table[j] != NULL
- && uhp_table[j]->uh_seq == uhp->uh_next.seq)
- {
- uhp->uh_next.ptr = uhp_table[j];
- SET_FLAG(j);
- break;
- }
- for (j = 0; j < num_head; j++)
- if (uhp_table[j] != NULL
- && uhp_table[j]->uh_seq == uhp->uh_prev.seq)
- {
- uhp->uh_prev.ptr = uhp_table[j];
- SET_FLAG(j);
- break;
- }
- for (j = 0; j < num_head; j++)
- if (uhp_table[j] != NULL
- && uhp_table[j]->uh_seq == uhp->uh_alt_next.seq)
- {
- uhp->uh_alt_next.ptr = uhp_table[j];
- SET_FLAG(j);
- break;
- }
- for (j = 0; j < num_head; j++)
- if (uhp_table[j] != NULL
- && uhp_table[j]->uh_seq == uhp->uh_alt_prev.seq)
- {
- uhp->uh_alt_prev.ptr = uhp_table[j];
- SET_FLAG(j);
- break;
- }
+ {
+ int seq = uhp->uh_next.seq;
+ uhp->uh_next.ptr = NULL;
+ for (j = 0; j < num_head; j++)
+ if (uhp_table[j] != NULL && i != j
+ && uhp_table[j]->uh_seq == seq)
+ {
+ uhp->uh_next.ptr = uhp_table[j];
+ SET_FLAG(j);
+ break;
+ }
+ }
+ {
+ int seq = uhp->uh_prev.seq;
+ uhp->uh_prev.ptr = NULL;
+ for (j = 0; j < num_head; j++)
+ if (uhp_table[j] != NULL && i != j
+ && uhp_table[j]->uh_seq == seq)
+ {
+ uhp->uh_prev.ptr = uhp_table[j];
+ SET_FLAG(j);
+ break;
+ }
+ }
+ {
+ int seq = uhp->uh_alt_next.seq;
+ uhp->uh_alt_next.ptr = NULL;
+ for (j = 0; j < num_head; j++)
+ if (uhp_table[j] != NULL && i != j
+ && uhp_table[j]->uh_seq == seq)
+ {
+ uhp->uh_alt_next.ptr = uhp_table[j];
+ SET_FLAG(j);
+ break;
+ }
+ }
+ {
+ int seq = uhp->uh_alt_prev.seq;
+ uhp->uh_alt_prev.ptr = NULL;
+ for (j = 0; j < num_head; j++)
+ if (uhp_table[j] != NULL && i != j
+ && uhp_table[j]->uh_seq == seq)
+ {
+ uhp->uh_alt_prev.ptr = uhp_table[j];
+ SET_FLAG(j);
+ break;
+ }
+ }
if (old_header_seq > 0 && old_idx < 0 && uhp->uh_seq == old_header_seq)
{
old_idx = i;