[gnote] Fix possible crash when removing tags



commit c30a8c12de2c319349ee51b99547b395e5b7576a
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Tue Oct 8 23:00:46 2019 +0300

    Fix possible crash when removing tags

 src/notebase.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/notebase.cpp b/src/notebase.cpp
index ab9df751..56a88692 100644
--- a/src/notebase.cpp
+++ b/src/notebase.cpp
@@ -216,8 +216,9 @@ void NoteBase::handle_link_rename(const Glib::ustring &, const Ptr &, bool)
 void NoteBase::delete_note()
 {
   // Remove the note from all the tags
-  for(NoteData::TagMap::const_iterator iter = data_synchronizer().data().tags().begin();
-      iter != data_synchronizer().data().tags().end(); ++iter) {
+  // remove_tag modifies map, so always iterate from start
+  NoteData::TagMap & thetags(data_synchronizer().data().tags());
+  for(NoteData::TagMap::const_iterator iter = thetags.begin(); iter != thetags.end(); iter = 
thetags.begin()) {
     remove_tag(iter->second);
   }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]