mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
common/cmdparse: no need to use (and leak to) the heap
Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Dan Mick <dan.mick@inktank.com>
This commit is contained in:
parent
5c945cd1b8
commit
6bab425342
@ -138,14 +138,14 @@ cmdmap_from_json(vector<string> cmd, map<string, cmd_vartype> *mapp, stringstrea
|
||||
// array is a vector of values. Unpack it to a vector
|
||||
// of strings, the only type we handle.
|
||||
vector<json_spirit::mValue> spvals = it->second.get_array();
|
||||
vector<string> *outvp = new vector<string>;
|
||||
vector<string> outv;
|
||||
for (vector<json_spirit::mValue>::iterator sv = spvals.begin();
|
||||
sv != spvals.end(); sv++) {
|
||||
if (sv->type() != json_spirit::str_type)
|
||||
throw(runtime_error("Can't handle arrays of non-strings"));
|
||||
outvp->push_back(sv->get_str());
|
||||
outv.push_back(sv->get_str());
|
||||
}
|
||||
(*mapp)[it->first] = *outvp;
|
||||
(*mapp)[it->first] = outv;
|
||||
}
|
||||
break;
|
||||
case json_spirit::str_type:
|
||||
|
Loading…
Reference in New Issue
Block a user