[3.15] gh-159739: Handle overlapping buffers in struct.pack_into (GH-159985) #160101

Merged
miss-islington opened 2:13pm on October 21, 2026 wanted to merge 1 commit into python/cpython 3.15 from
backport-31a7d99-3.15
miss-islington authored
of work during October 21
Diff Delta:
0
About 0 Diff Delta/hour
Classified as:  General

miss-islington's Description of Work

struct.pack_into() can use the same bytearray as both the destination and an s or p value. The copy then passes overlapping regions to memcpy, which is undefined in C and can produce platform-dependent results or a sanitizer abort. memmove makes the overlapping copy defined.
(cherry picked from commit 31a7d994a559a421814ca9e8edfcab21ae4a5b36)

Co-authored-by: Jelle Zijlstra [email protected]


  • Issue: gh-159739
    <!-- /gh-issue-number -->

2 total changed files
(1 file ignored)
Loading changes...
You’ve reached the end
Please mind the merge button