Usermode/libc++ - Fix off by one in map indexing
authorJohn Hodge (sonata) <[email protected]>
Thu, 6 Nov 2014 22:45:45 +0000 (06:45 +0800)
committerJohn Hodge (sonata) <[email protected]>
Thu, 6 Nov 2014 22:45:45 +0000 (06:45 +0800)
Usermode/Libraries/libc++.so_src/include_exp/_libcxx_helpers.h
Usermode/Libraries/libc++.so_src/include_exp/map

index 755337d..bd3b805 100644 (file)
@@ -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
index 10bae93..7f7e7c3 100644 (file)
@@ -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

UCC git Repository :: git.ucc.asn.au