Skip to content

Commit

Permalink
Fixed a bug with map iterator++.
Browse files Browse the repository at this point in the history
We were derefing end() which is invalid.
  • Loading branch information
AWoloszyn committed Feb 23, 2018
1 parent 00bc3c7 commit 7b70d4a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gapil/runtime/cc/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ const typename Map<K, V>::iterator& Map<K, V>::iterator::operator++() {
size_t offset = elem - reinterpret_cast<element*>(map->elements);
for (size_t i = offset; i < map->capacity; ++i) {
++elem;
if (i == map->capacity - 1) {
break;
}
if (elem->used == GAPIL_MAP_ELEMENT_FULL) {
break;
}
Expand Down Expand Up @@ -268,6 +271,9 @@ typename Map<K, V>::const_iterator& Map<K, V>::const_iterator::operator++() {
size_t offset = elem - reinterpret_cast<element*>(map->elements);
for (size_t i = offset; i < map->capacity; ++i) {
++elem;
if (i == map->capacity - 1) {
break;
}
if (elem->used == GAPIL_MAP_ELEMENT_FULL) {
break;
}
Expand Down

0 comments on commit 7b70d4a

Please sign in to comment.