#138 vector.hpp out-of-bound access

0.60
closed-accepted
None
5
2006-11-13
2006-08-30
No

std::vector::end() returns an iterator that
points just beyond the end of the vector.

So &*thin->end() is no valid code, because
it is a out of bound access.

std::vector::back() returns a reference to
the last element and a pointer to the last
element is: &back().

Discussion

  • Peter Kuemmel

    Peter Kuemmel - 2006-08-30

    Logged In: YES
    user_id=1159765

    Update patch:

    To get a pointer so the same position as
    before we must use: &back()+1

     
  • Peter Kuemmel

    Peter Kuemmel - 2006-08-30
     
  • Kevin Atkinson

    Kevin Atkinson - 2006-08-30
    • assigned_to: nobody --> kevina
     
  • Kevin Atkinson

    Kevin Atkinson - 2006-08-30

    Logged In: YES
    user_id=6591

    Note from email:

    >> std::vector::end() returns an iterator that
    >> points just beyond the end of the vector.
    >>
    >> So &*thin->end() is no valid code, because
    >> it is a out of bound access.
    >>
    >> std::vector::back() returns a reference to
    >> the last element and a pointer to the last
    >> element is: &back().
    >
    > Did this cause a problem for you?

    Yes, the app crashes.

    > I wonder what implementation of vector where
    > &*this->end() != &back()+1

    The STL of msvc is very pedantic in the debug mode.
    It checks before every dereferencing.

     
  • Kevin Atkinson

    Kevin Atkinson - 2006-11-13
    • milestone: --> 0.60
     
  • Kevin Atkinson

    Kevin Atkinson - 2006-11-13

    Logged In: YES
    user_id=6591

    Accepted. Will appear in Aspell 0.60.5

     
  • Kevin Atkinson

    Kevin Atkinson - 2006-11-13
    • status: open --> closed-accepted
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks