[PATCH] editors: Fix potential deref-of-null

ant.v.moryakov at gmail.com ant.v.moryakov at gmail.com
Fri Apr 18 10:21:36 UTC 2025


From: Maks Mishin <maks.mishinFZ at gmail.com>

Signed-off-by: Maks Mishin <maks.mishinFZ at gmail.com>
---
 editors/vi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/editors/vi.c b/editors/vi.c
index 2645afe..8dd45ef 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1990,6 +1990,9 @@ static int file_insert(const char *fn, char *p, int initial)
 	if (p > end)
 		p = end;
 
+	if (fn == NULL)
+		return cnt;
+
 	fd = open(fn, O_RDONLY);
 	if (fd < 0) {
 		if (!initial)
-- 
2.43.0


More information about the busybox mailing list