Mercurial > hg > octave-avbm
changeset 11548:50a7935f2512
Don't invalidate iterators when calling std::map::erase, found by cppcheck
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Sun, 16 Jan 2011 08:58:46 -0600 |
parents | e1851653d59c |
children | beb4f0f27a32 |
files | src/ChangeLog src/DLD-FUNCTIONS/urlwrite.cc src/symtab.h |
diffstat | 3 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-01-15 Jordi GutiƩrrez Hermoso <jordigh@gmail.com> + + * symtab.h (do_clear_global_pattern): Reword so as to not + invalidate iterators when calling std::map::erase(). + * DLD-FUNCTIONS/urwlwrite.cc (~curl_handles): Ditto. + 2011-01-15 Rik <octave@nomad.inbox5.com> * src/dirfns.cc, src/help.cc, src/input.cc, src/load-save.cc,
--- a/src/DLD-FUNCTIONS/urlwrite.cc +++ b/src/DLD-FUNCTIONS/urlwrite.cc @@ -613,8 +613,7 @@ { // Remove the elements of the map explicitly as they should // be deleted before the call to curl_global_cleanup - for (iterator pa = begin (); pa != end (); pa++) - map.erase (pa); + map.erase (begin(), end()); curl_global_cleanup (); }
--- a/src/symtab.h +++ b/src/symtab.h @@ -2221,11 +2221,15 @@ sr.unmark_global (); } + for (global_table_iterator q = global_table.begin (); - q != global_table.end (); q++) + q != global_table.end ();) { if (pattern.match (q->first)) - global_table.erase (q); + global_table.erase (q++); //Gotta be careful to not + //invalidate iterators + else + q++; }