Opened 8 years ago

Closed 7 years ago

#11163 closed Bugs (fixed)

generator::set_default_messages_domain either crashes or have unexpected side effects

Reported by: Anders Dalvander <boost@…> Owned by: Artyom Beilis
Milestone: To Be Determined Component: locale
Version: Boost 1.57.0 Severity: Problem
Keywords: crash Cc:

Description

Calling generator::set_default_messages_domain before calling generator::add_messages_domain using the same domain results in calling vector::erase using an invalid iterator, which results in a crash.

Calling generator::set_default_messages_domain after calling generator::add_messages_domain using the same domain results in adding the domain twice to the vector.

This is due to using operator== instead of operator!= when comparing iterator to vector::end().

Fix:

void generator::set_default_messages_domain(std::string const &domain)
{
   std::vector<std::string>::iterator p;
   if((p=std::find(d->domains.begin(),d->domains.end(),domain)) != d->domains.end()) {
      d->domains.erase(p);
   }
   d->domains.insert(d->domains.begin(),domain);
}

Change History (2)

comment:1 by Akira Takahashi <faithandbrave@…>, 7 years ago

This issue fixed? The issue is listed to Boost 1.60.0 release-note.

comment:2 by Artyom Beilis, 7 years ago

Resolution: fixed
Status: newclosed

Fixed in 1.60

Note: See TracTickets for help on using tickets.