From ca9a575116285753b48fd8e0ae6dcdbf8a4af5b1 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Fri, 7 Nov 2014 06:45:45 +0800 Subject: [PATCH] Usermode/libc++ - Fix off by one in map indexing --- .../Libraries/libc++.so_src/include_exp/_libcxx_helpers.h | 1 + Usermode/Libraries/libc++.so_src/include_exp/map | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Usermode/Libraries/libc++.so_src/include_exp/_libcxx_helpers.h b/Usermode/Libraries/libc++.so_src/include_exp/_libcxx_helpers.h index 755337df..bd3b805c 100644 --- a/Usermode/Libraries/libc++.so_src/include_exp/_libcxx_helpers.h +++ b/Usermode/Libraries/libc++.so_src/include_exp/_libcxx_helpers.h @@ -18,6 +18,7 @@ namespace _sys { extern void abort() __asm__ ("abort") __attribute__((noreturn)); extern void debug(const char *, ...); +extern void hexdump(const char *, const void *, unsigned int); }; #if _CXX11_AVAIL diff --git a/Usermode/Libraries/libc++.so_src/include_exp/map b/Usermode/Libraries/libc++.so_src/include_exp/map index 10bae939..7f7e7c3c 100644 --- a/Usermode/Libraries/libc++.so_src/include_exp/map +++ b/Usermode/Libraries/libc++.so_src/include_exp/map @@ -59,9 +59,11 @@ public: return !(*this == x); } value_type& operator*() { + _libcxx_assert(m_index < m_map->m_size); return m_map->m_items[m_index]; } value_type* operator->() { + _libcxx_assert(m_index < m_map->m_size); return &m_map->m_items[m_index]; } }; @@ -171,7 +173,6 @@ public: iterator it = upper_bound(k); if( it == end() || m_comp(k, it->first) ) { // if k < it->first, no match insert_at(it.m_index, value_type(k,mapped_type()) ); - ++ it; } return it->second; } @@ -343,9 +344,8 @@ private: #endif } void insert_at(size_type ofs, const value_type& val) { - //assert( ofs == 0 || m_comp(m_items[ofs-1].first, val.first) ); - //assert( ofs == m_size || m_comp(m_items[ofs].first, val.first) ); - //::_sys::debug("map::insert_at(%i,)", ofs); + //_libcxx_assert( ofs == 0 || m_comp(m_items[ofs-1].first, val.first) ); + //_libcxx_assert( ofs == m_size || m_comp(m_items[ofs].first, val.first) ); // Resize up reserve( m_size + 1 ); // Move following items up -- 2.20.1