Skip to content

Bytes's Drop implementation can try to free a null pointer #340

@sfackler

Description

@sfackler

This program appears to try to free a null pointer.

fn main() {
    let buf = BytesMut::with_capacity(1);
    buf.freeze();
}
#4  0x000055555555f117 in __rg_dealloc (arg0=0x0, arg1=1, arg2=1) at src/main.rs:6
#5  0x00005555555e1123 in alloc::alloc::dealloc (ptr=0x0, layout=...) at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/liballoc/alloc.rs:106
#6  0x00005555555e0cea in <alloc::alloc::Global as core::alloc::Alloc>::dealloc (self=0x7fffffffe8b0, ptr=..., layout=...) at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/liballoc/alloc.rs:177
#7  0x00005555555e1ec9 in alloc::raw_vec::RawVec<T,A>::dealloc_buffer (self=0x7fffffffe8b0) at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/liballoc/raw_vec.rs:742
#8  0x00005555555e1fdf in <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop (self=0x7fffffffe8b0) at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/liballoc/raw_vec.rs:751
#9  0x00005555555e0b9f in core::ptr::real_drop_in_place () at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libcore/ptr/mod.rs:175
#10 0x00005555555e0b32 in core::ptr::real_drop_in_place () at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libcore/ptr/mod.rs:175
#11 0x00005555555e2237 in core::mem::drop (_x=<error reading variable: Cannot access memory at address 0x2>) at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libcore/mem/mod.rs:706
#12 0x00005555555ded38 in bytes::bytes::shared_drop (data=0x7fffffffe928, ptr=0x1 <error: Cannot access memory at address 0x1>, len=0) at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.2/src/bytes.rs:799
#13 0x000055555555ef70 in <bytes::bytes::Bytes as core::ops::drop::Drop>::drop (self=0x7fffffffe918) at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.2/src/bytes.rs:435

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