{"push_id":951380792,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"de637db263d101b4fba360c75d0432a8e35c3e15","before":"949215c589cd5eabc2973b179d4c79f2bcbb5738","commits":[{"sha":"de637db263d101b4fba360c75d0432a8e35c3e15","author":{"email":"96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@efcs.ca","name":"Eric Fiselier"},"message":"[libcxx] Fix undefined behavior in forward_list\n\nSummary:\nThis patch is similar to the <list> fix but it has a few differences. This patch doesn't use a `__link_pointer` typedef because we don't need to change the linked list pointers because `forward_list` never stores a  `__forward_begin_node` in the linked list itself. \n\nThe issue with `forward_list` is that the iterators store pointers to `__forward_list_node` and not `__forward_begin_node`. This is incorrect because `before_begin()` and `cbefore_begin()` return iterators that point to a `__forward_begin_node`. This means we incorrectly downcast the `__forward_begin_node` pointer to a `__node_pointer`. This downcast itself is sometimes UB but it cannot be safely removed until ABI v2. The more common cause of UB is when we deference the downcast pointer. (for example `__ptr_->__next_`). This can be fixed without an ABI break by upcasting `__ptr_` before accessing it.\n\nThe fix is as follows:\n\n1. Introduce a `__iter_node_pointer` typedef that works  similar to `__link_pointer` in the last patch. In ABI v2 it is always a typedef for `__begin_node_pointer`.\n2. Change the `__before_begin()` method to return the correct pointer type (`__begin_node_pointer`),\n    Previously it incorrectly downcasted  the  `__forward_begin_node` to a `__node_pointer`  so it could be used to constructor the iterator types.\n3. Change `__forward_list_iterator` and `__forward_list_const_iterator`  in the following way:\n    1. Change `__node_pointer __ptr_;` member to  have the `__iter_node_pointer` type instead. \n    2. Add additional private constructors that accept `__begin_node_pointer` in addition to `__node_pointer` and then correctly cast them to the stored `__iter_node_pointer` type. \n    3. Add  `__get_begin()` and `__get_node_unchecked()` accessor methods that correctly cast `__ptr_` to the expected pointer type. `__get_begin()` is always safe to use and should be \n       preferred. `__get_node_unchecked()` can only be used on a deferencible iterator.\n4. Replace direct access to `__forward_list_iterator::__ptr_`  with the safe accessor methods.\n  \n\n\nReviewers: mclow.lists, EricWF\n\nSubscribers: cfe-commits\n\nDifferential Revision: http://reviews.llvm.org/D15836\n\ngit-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258888 91177308-0d34-0410-b5e6-96231b3b80d8","distinct":true,"url":"https://api.github.com/repos/llvm-project/libcxx/commits/de637db263d101b4fba360c75d0432a8e35c3e15"}]}