mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
eval: Fix uniq() crash in legacy test 055
This commit is contained in:
parent
7572d5ac5a
commit
d11884db49
@ -15232,6 +15232,8 @@ item_compare_end:
|
||||
// When the result would be zero, compare the item indexes. Makes the
|
||||
// sort stable.
|
||||
if (res == 0 && !keep_zero) {
|
||||
// WARNING: When using uniq si1 and si2 are actually listitem_T **, no
|
||||
// indexes are there.
|
||||
res = si1->idx > si2->idx ? 1 : -1;
|
||||
}
|
||||
return res;
|
||||
@ -15297,6 +15299,8 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero)
|
||||
// When the result would be zero, compare the pointers themselves. Makes
|
||||
// the sort stable.
|
||||
if (res == 0 && !keep_zero) {
|
||||
// WARNING: When using uniq si1 and si2 are actually listitem_T **, no
|
||||
// indexes are there.
|
||||
res = si1->idx > si2->idx ? 1 : -1;
|
||||
}
|
||||
|
||||
@ -15462,7 +15466,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
|
||||
listitem_T *prev_li = NULL;
|
||||
TV_LIST_ITER(l, li, {
|
||||
if (prev_li != NULL) {
|
||||
if (item_compare_func_ptr(prev_li, li) == 0) {
|
||||
if (item_compare_func_ptr(&prev_li, &li) == 0) {
|
||||
ptrs[i++].item = prev_li;
|
||||
}
|
||||
if (info.item_compare_func_err) {
|
||||
|
@ -102,6 +102,8 @@ describe('NULL', function()
|
||||
'E742: Cannot change value of reverse() argument', 0)
|
||||
null_expr_test('makes sort() error out', 'sort(L)',
|
||||
'E742: Cannot change value of sort() argument', 0)
|
||||
null_expr_test('makes uniq() error out', 'uniq(L)',
|
||||
'E742: Cannot change value of uniq() argument', 0)
|
||||
null_expr_test('does not crash extend()', 'extend(L, [1])', 'E742: Cannot change value of extend() argument', 0)
|
||||
null_expr_test('does not crash extend() (second position)', 'extend([1], L)', 0, {1})
|
||||
null_expr_test('makes join() return empty string', 'join(L, "")', 0, '')
|
||||
|
Loading…
Reference in New Issue
Block a user