Skip to content

Commit

Permalink
librados: always free buffer allocated by md_config_t::_get_val
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jdurgin authored and Samuel Just committed Sep 25, 2012
1 parent e6ced04 commit 2371352
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/librados/librados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2371352

Please sign in to comment.