The const Option* needs to remain alive only until the next clear(). Keep
the reference in ConfigMap and clean it up then.
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit
9397a46aec88e287d56a6286ed4319f65d9c1f31)
Fixes: https://tracker.ceph.com/issues/48381
Conflicts:
src/mon/ConfigMap.h: trivial resolution
Section global;
std::map<std::string,Section> by_type;
std::map<std::string,Section> by_id;
+ std::list<std::unique_ptr<Option>> stray_options;
Section *find_section(const std::string& name) {
if (name == "global") {
global.clear();
by_type.clear();
by_id.clear();
+ stray_options.clear();
}
void dump(Formatter *f) const;
void generate_entity_map(
}
if (!opt) {
dout(10) << __func__ << " unrecognized option '" << name << "'" << dendl;
- opt = new Option(name, Option::TYPE_STR, Option::LEVEL_UNKNOWN);
- // FIXME: this will be leaked!
+ config_map.stray_options.push_back(
+ std::unique_ptr<Option>(
+ new Option(name, Option::TYPE_STR, Option::LEVEL_UNKNOWN)));
+ opt = config_map.stray_options.back().get();
}
string err;