Fix incorrect iterator manipulation
authorMikko Rasa <tdb@tdb.fi>
Wed, 1 Sep 2021 00:12:09 +0000 (03:12 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 1 Sep 2021 00:12:09 +0000 (03:12 +0300)
Now that opts is a vector, erase invalidates iterators.

source/core/getopt.cpp

index 6f7b1f807c9d719d3829959db91370860a62fabe..13e235f25152912a5f86466b129cd2a9bf5999c7 100644 (file)
@@ -32,7 +32,7 @@ GetOpt::OptionImpl &GetOpt::add_option(char s, const string &l, const Store &t,
                if((s!=0 && (*i)->get_short()==s) || (*i)->get_long()==l)
                {
                        delete *i;
-                       opts.erase(i++);
+                       i = opts.erase(i);
                }
                else
                        ++i;