[vim/vim] Fix invalid pointer casting in string_convert() arguments (PR #19672)

4 views
Skip to first unread message

James McCoy

unread,
Mar 13, 2026, 11:13:53 PMMar 13
to vim/vim, Subscribed

string_convert()/string_convert_ext() accept an "int *lenp" parameter,
however a few call sites were taking the address of a possibly larger
type (long, size_t) and casting it as an int * when calling these
functions.

On big-endian platforms, this passes the (likely) zeroed high bytes of
the known length through to string_convert(). This indicates it received
an empty string and returns an allocated empty string rather than
converting the input. This is exhibited by test failures like

From test_blob.vim:
Found errors in Test_blob2str_multi_byte_encodings():
command line..script src/testdir/runtest.vim[636]..function RunTheTest[63]..Test_blob2str_multi_byte_encodings line 2: Expected ['Hello'] but got ['']
command line..script src/testdir/runtest.vim[636]..function RunTheTest[63]..Test_blob2str_multi_byte_encodings line 3: Expected ['Hello'] but got ['']
command line..script srctestdir/runtest.vim[636]..function RunTheTest[63]..Test_blob2str_multi_byte_encodings line 6: Expected ['Hello'] but got ['']

Instead, use a temporary local int variable as the in/out variable for
string_convert() and assign the result back to the larger typed length
variable post-conversion.


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

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

Commit Summary

  • dfa3eb0 Fix invalid pointer casting in string_convert() arguments

File Changes

(2 files)

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/19672@github.com>

Christian Brabandt

unread,
Mar 15, 2026, 5:03:28 AMMar 15
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19672)

thanks


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/19672/c4062607088@github.com>

Christian Brabandt

unread,
Mar 15, 2026, 5:04:09 AMMar 15
to vim/vim, Subscribed

Closed #19672 via b00f441.


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/19672/issue_event/23582684641@github.com>

John Marriott

unread,
Mar 28, 2026, 9:45:41 PM (9 hours ago) Mar 28
to vim/vim, Subscribed
basilisk0315 left a comment (vim/vim#19672)

Hi @jamessan,

A question regarding this issue. Passing a larger integer to list_append_string() is happening in other parts of the code as well (eg. evalfunc.c, line 6280, or register.c line 1100).

Are these causing issues as well?

I am inclined to think that other instances of this should be changed as well. Thoughts?

Cheers
John


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/19672/c4149205551@github.com>

zeertzjq

unread,
Mar 28, 2026, 9:48:33 PM (9 hours ago) Mar 28
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#19672)

What does that have to do the pointer conversion?


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/19672/c4149209048@github.com>

John Marriott

unread,
Mar 28, 2026, 10:03:09 PM (8 hours ago) Mar 28
to vim/vim, Subscribed
basilisk0315 left a comment (vim/vim#19672)

Oh no. I've realised what I said...

Never mind, ignore me. Having a senior moment.

Sorry.


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/19672/c4149227089@github.com>

Reply all
Reply to author
Forward
0 new messages