d209e6f1c0 (master): search_nonascii(): Replace UB pointer cast with memcpy

0 views
Skip to first unread message

Alan Wu

unread,
Dec 16, 2025, 1:06:34 PM (13 hours ago) Dec 16
to ruby...@g.ruby-lang.org
Alan Wu 2025-11-27 02:59:37 +0000 (Thu, 27 Nov 2025)

New Revision: d209e6f1c0

https://github.com/ruby/ruby/commit/d209e6f1c0

Log:
search_nonascii(): Replace UB pointer cast with memcpy

Casting a pointer to create an unaligned one is undefined behavior in C
standards. Use memcpy to express the unaligned load instead to play by
the rules.

Practically, this yields the same binary output in many situations
while fixing the crash in [Bug #21715].

Modified files:
string.c
Reply all
Reply to author
Forward
0 new messages