[vim/vim] Fix invalid pointer cast in list_slice_or_index() (PR #19952)

5 views
Skip to first unread message

James McCoy

unread,
Apr 10, 2026, 11:25:49 PM (2 days ago) Apr 10
to vim/vim, Subscribed

check_range_index_one() expects a long * parameter, but n1 is a
varnumber_T. On big-endian platforms where long is not 64-bit, casting
the varnumber_T * to long * passes a pointer to the wrong bytes.

Use a local long variable, after validating the value fits within a
long, and pass that pointer to check_range_index_one().

Validated on 32-bit powerpc, s390x, and x86.

Closes: #19798


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19952

Commit Summary

  • c9aaac5 Fix invalid pointer cast in list_slice_or_index()

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19952@github.com>

Christian Brabandt

unread,
Apr 11, 2026, 6:15:52 AM (18 hours ago) Apr 11
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19952)

thanks for finding this out. Is it possible to test and validate this so that it doesn't regress in the future?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19952/c4229252361@github.com>

Rhialto The M.

unread,
Apr 11, 2026, 7:18:50 AM (17 hours ago) Apr 11
to vim/vim, Subscribed
Rhialto left a comment (vim/vim#19952)

In this line

if (n1 < 0 || n1 >= len || n1 > LONG_MAX || n1 < LONG_MIN)

the check for n1 < LONG_MIN seems to be superfluous because there is already a check for n1 < 0 (and LONG_MIN is surely at most 0). Of course the compiler will likely optimize it away for the same reason.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19952/c4229329897@github.com>

James McCoy

unread,
Apr 11, 2026, 8:25:47 AM (16 hours ago) Apr 11
to vim/vim, Push

@jamessan pushed 1 commit.

  • 2746323 Fix invalid pointer cast in list_slice_or_index()


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19952/before/c9aaac55de329264da5e6f762f80ffd26b5a4f6d/after/2746323abacb6699aad296c3a9fde00d5287e3ca@github.com>

James McCoy

unread,
Apr 11, 2026, 8:27:28 AM (16 hours ago) Apr 11
to vim/vim, Subscribed
jamessan left a comment (vim/vim#19952)

Is it possible to test and validate this so that it doesn't regress in the future?

I'm not sure how, without adding big-endian build/test to CI.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19952/c4229419285@github.com>

Christian Brabandt

unread,
Apr 11, 2026, 10:58:17 AM (14 hours ago) Apr 11
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19952)

thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19952/c4229626675@github.com>

Christian Brabandt

unread,
Apr 11, 2026, 11:08:16 AM (14 hours ago) Apr 11
to vim/vim, Subscribed

Closed #19952 via 8fd37e4.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19952/issue_event/24408955829@github.com>

Reply all
Reply to author
Forward
0 new messages