Skip to content

Condition handlers can unsoundly alias mutable stack variables #6459

Closed
@brson

Description

@brson

In this example, keep_reading is mutable and aliased.

    fn read_to_end(&mut self) -> ~[u8] {
        let mut buf = vec::with_capacity(DEFAULT_BUF_SIZE);
        let mut keep_reading = true;
        do read_error::cond.trap(|e| {
            if e.kind == EndOfFile {
                keep_reading = false;
            }
        }).in {
            while keep_reading {
                self.push_bytes(&mut buf, DEFAULT_BUF_SIZE)
            }
        }
        return buf;
    }

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