mirror of
https://github.com/ceph/ceph
synced 2025-01-18 09:02:08 +00:00
librados: always free buffer allocated by md_config_t::_get_val
CID 717083: Resource leak (RESOURCE_LEAK) At (3): Variable "str" going out of scope leaks the storage it points to. Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
parent
a677f47926
commit
4567a6df2f
@ -1113,11 +1113,13 @@ int librados::Rados::conf_set(const char *option, const char *value)
|
||||
|
||||
int librados::Rados::conf_get(const char *option, std::string &val)
|
||||
{
|
||||
char *str;
|
||||
char *str = NULL;
|
||||
md_config_t *conf = client->cct->_conf;
|
||||
int ret = conf->get_val(option, &str, -1);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
free(str);
|
||||
return ret;
|
||||
}
|
||||
val = str;
|
||||
free(str);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user