Skip to content

get_channels_peak_values passes a read-only pointer to a call that writes through it #79

Closed

Description

@HEnquist

AudioMeterInformation::get_channels_peak_values calls GetChannelsPeakValues(&mut peaks) from the windows crate.
The generated wrapper converts the slice with transmute(afpeakvalues.as_ptr()).
The pointer comes from a shared reborrow, so it only has read-only provenance.
Windows writes the peak values through it, which is undefined behaviour.

This is the same pattern as microsoft/windows-rs#5189, where GetKeyboardState miscompiles in release builds.
That case is a stack array read at constant indices.
Here it's a heap Vec with a runtime length, so an actual miscompile is less likely, but it's still UB.

Affects v0.24.0 to v0.26.0.
The fix is to call the vtable entry directly with peaks.as_mut_ptr(), like GetChannelsPeakValuesSlice does on the drop-umbrella-windows branch (#74).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions