fix tiny-Vim crashes with fuzzy buffer completion

This commit is contained in:
wjiang 2024-12-13 11:40:53 +08:00
parent 94724ad247
commit e21e64b229
2 changed files with 111 additions and 1 deletions

View File

@ -0,0 +1,103 @@
From dff3c9c1a789351a741b6a430862c8b2a0eff383 Mon Sep 17 00:00:00 2001
From: 826814741_6 <44406129+826814741-6@users.noreply.github.com>
Date: Tue, 10 Dec 2024 17:15:14 +0100
Subject: [PATCH] patch 9.1.0918: tiny Vim crashes with fuzzy buffer completion
Problem: tiny Vim crashes with fuzzy buffer completion
Solution: Adjust #ifdefs in ExpandBufnames() (826814741_6)
closes: #16200
Signed-off-by: h-east <h.east.727@gmail.com>
Signed-off-by: 826814741_6 <44406129+826814741-6@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
---
src/buffer.c | 4 ++--
src/testdir/Make_all.mak | 6 ++++--
src/testdir/test29.in | 14 ++++++++++++++
src/testdir/test29.ok | 1 +
4 files changed, 21 insertions(+), 4 deletions(-)
create mode 100644 src/testdir/test29.in
create mode 100644 src/testdir/test29.ok
diff --git a/src/buffer.c b/src/buffer.c
index 3b05f25d7f705b..147d20dc78f0ff 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2956,9 +2956,9 @@ ExpandBufnames(
if (!fuzzy && patc != pat)
vim_free(patc);
-#ifdef FEAT_VIMINFO
if (!fuzzy)
{
+#ifdef FEAT_VIMINFO
if (matches != NULL)
{
int i;
@@ -2978,13 +2978,13 @@ ExpandBufnames(
}
vim_free(matches);
}
+#endif
}
else
{
if (fuzzymatches_to_strmatches(fuzmatch, file, count, FALSE) == FAIL)
return FAIL;
}
-#endif
*num_file = count;
return (count == 0 ? FAIL : OK);
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index bdf058c1ec43a1..7285354838805a 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -20,7 +20,8 @@ SCRIPTS_TINY = \
test24 \
test25 \
test26 \
- test27
+ test27 \
+ test29
SCRIPTS_TINY_OUT = \
test10.out \
@@ -31,7 +32,8 @@ SCRIPTS_TINY_OUT = \
test24.out \
test25.out \
test26.out \
- test27.out
+ test27.out \
+ test29.out
# Tests for Vim9 script.
TEST_VIM9 = \
diff --git a/src/testdir/test29.in b/src/testdir/test29.in
new file mode 100644
index 00000000000000..047803c60ff7bd
--- /dev/null
+++ b/src/testdir/test29.in
@@ -0,0 +1,14 @@
+Test for buffer name completion when 'wildoptions' contains "fuzzy"
+(Confirm that Vim does not crash)
+
+STARTTEST
+:set wildoptions=fuzzy
+:new buf_a
+:b buf_a
+:q!
+:set wildoptions&
+:$w! test.out
+:qa!
+ENDTEST
+
+I'm alive!
diff --git a/src/testdir/test29.ok b/src/testdir/test29.ok
new file mode 100644
index 00000000000000..6a0a7c94510a8e
--- /dev/null
+++ b/src/testdir/test29.ok
@@ -0,0 +1 @@
+I'm alive!

View File

@ -14,7 +14,7 @@
Name: vim
Epoch: 2
Version: %{baseversion}.%{patchlevel}
Release: 14
Release: 15
Summary: Vim is a highly configurable text editor for efficiently creating and changing any kind of text.
License: Vim and MIT
URL: http://www.vim.org
@ -52,6 +52,7 @@ Patch6017: backport-CVE-2024-43374.patch
Patch6018: backport-CVE-2024-43802.patch
Patch6019: backport-patch-9.1.0722-crash-with-large-id-in-text_prop-interface.patch
Patch6020: backport-patch-9.1.0730-crash-with-cursor-screenline-and-narrow-window.patch
Patch6021: backport-patch-9.1.0918-tiny-vim-crashes-with-fuzzy-buffer-completion.patch
Patch9000: bugfix-rm-modify-info-version.patch
Patch9001: fix-CVE-2024-47814.patch
@ -460,6 +461,12 @@ LC_ALL=en_US.UTF-8 make -j1 test || echo "Warning: Please check tests."
%{_mandir}/man1/evim.*
%changelog
* Fri Dec 13 2024 wangjiang <app@cameyan.com> - 2:9.0.2092-15
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix tiny-Vim crashes with fuzzy buffer completion
* Tue Nov 12 2024 wangjiang <app@cameyan.com> - 2:9.0.2092-14
- Type:bugfix
- ID:NA