Skip to content

Potential null pointer dereference in vim #18437

@lionheartys

Description

@lionheartys

Steps to reproduce

Using the vim build compiled with Clang-LLVM 16 (version 16)
Configuration options: ./configure --with-features=huge --enable-gui=none
After the compilation is complete, use the binary executable file /vim/src/vim to execute: vim -u NONE -i NONE -X -Z -m -n -e -s -S POC -c :qa!

Image Image Image

Expected behaviour

Vim should not crash. The code should safely handle any null pointer situations and prevent segmentation faults.

Version of Vim

9.1.1792

Environment

OS:Ubuntu 22.04.5 LTS
$TERM: xterm
Shell: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

Logs and stack traces

The crash is triggered by a null pointer dereference during normal command execution. The issue seems to originate from the /src/diff.c:calculate_topfill_and_topline() function when accessing the thistopdiff pointer, which can be NULL.

When I use GDB to debug this crash, the call stack and the crash part are shown in the attached figure(The information in the Logs and stack traces section cannot be attached. I can only put the gdb debugging process in the Steps to reproduce section. I'm sorry.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions