Skip to content

converters: fix signed left shift UB in integer converters - #1189

Open
nat3Github wants to merge 1 commit into
PortAudio:masterfrom
nat3Github:converters-signed-shift-ub
Open

nat3Github wants to merge 1 commit into
PortAudio:masterfrom
nat3Github:converters-signed-shift-ub

Conversation

@nat3Github

Copy link
Copy Markdown

Int24 sample assembly shifted a byte >= 0x80 into the sign bit, and the Int16/Int8/UInt8 and dither paths left-shifted negative values.

Both are undefined behavior (C11 6.5.7p4) and trap under -fsanitize=undefined, i.e. test/patest_converters.
pr shifts as PaUint32 instead; output is bit-identical.

Int24 sample assembly shifted a byte >= 0x80 into the sign bit, and the
Int16/Int8/UInt8 and dither paths left-shifted negative values. Both are
undefined behavior (C11 6.5.7p4) and trap under -fsanitize=undefined,
e.g. test/patest_converters. Shift as PaUint32 instead; output is
bit-identical.
@philburk philburk added this to the V19.8 milestone Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants