Opened 12 years ago

Last modified 12 years ago

#4151 new Bugs

option_description::option_description(3 args) is exception-unsafe

Reported by: anonymous Owned by: Vladimir Prus
Milestone: Boost 1.43.0 Component: program_options
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

Given the code in libs/program_options/src/options_description.cpp:

option_description::
option_description(const char* name,
                   const value_semantic* s,
                   const char* description)
: m_description(description), m_value_semantic(s)
{
    this->set_name(name);
}

s leaks in case if initialization of m_description throws.

The simplest cure is to make option::description::m_value_semantic member to be before all other members.

Change History (2)

comment:1 by anonymous, 12 years ago

Summary: option_description::option_description(3 params) is exception-unsafeoption_description::option_description(3 args) is exception-unsafe

comment:2 by anonymous, 12 years ago

The proper solution is to use smart pointers everywhere.

Note: See TracTickets for help on using tickets.