8000 Undefined behaviour in winmm backend · Issue #137 · Boddlnagg/midir · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Undefined behaviour in winmm backend #137
Open
@barafael

Description

@barafael

Here, a packet is filled by bytes from a message:

let packet: u32 = 0;
let ptr = &packet as *const u32 as *mut u8;
for i in 0..nbytes {
unsafe { *ptr.offset(i as isize) = message[i] };
}

This is undefined behaviour, because the address of an immutable u32 is taken and cast to a *mut u8, which is then written to in an unsafe block.

I have fixes ready in #136 but these are part of a rather large patchset, so if you like I can send a small patch ahead, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0