Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle overflow properly in core::slice #25300

Merged
merged 3 commits into from
May 12, 2015

Commits on May 11, 2015

  1. Handle overflow properly in core::slice

    core::slice was originally written to tolerate overflow (notably, with
    slices of zero-sized elements), but it was never updated to use wrapping
    arithmetic when overflow traps were added.
    
    Also correctly handle the case of calling .nth() on an Iter with a
    zero-sized element type. The iterator was assuming that the pointer
    value of the returned reference was meaningful, but that's not true for
    zero-sized elements.
    
    Fixes rust-lang#25016.
    lilyball committed May 11, 2015
    Configuration menu
    Copy the full SHA
    52efe55 View commit details
    Browse the repository at this point in the history
  2. Reintroduce non-null assumptions in core::slice iterators

    The previous assumptions were not valid for slices of zero-sized
    elements.
    lilyball committed May 11, 2015
    Configuration menu
    Copy the full SHA
    e1e34e9 View commit details
    Browse the repository at this point in the history
  3. Avoid returning a slice with a null pointer from Iter.as_slice()

    core::slice::Iter.ptr can be null when iterating a slice of zero-sized
    elements, but the pointer value used for the slice itself cannot. Handle
    this case by always returning a dummy pointer for slices of zero-sized
    elements.
    lilyball committed May 11, 2015
    Configuration menu
    Copy the full SHA
    f2614f5 View commit details
    Browse the repository at this point in the history