summaryrefslogtreecommitdiffstats
path: root/src/librados
diff options
context:
space:
mode:
authorJosh Durgin <josh.durgin@inktank.com>2012-09-25 00:12:11 +0200
committerJosh Durgin <josh.durgin@inktank.com>2012-09-25 02:57:33 +0200
commit4567a6df2f45e947be0eb248529f7610ecc2305c (patch)
tree4d55dafbd35839f6c9332ac0d7ffdae892f467a7 /src/librados
parentlibrados: fix use without NULL check in rados_pool_list (diff)
downloadceph-4567a6df2f45e947be0eb248529f7610ecc2305c.tar.xz
ceph-4567a6df2f45e947be0eb248529f7610ecc2305c.zip
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>
Diffstat (limited to 'src/librados')
-rw-r--r--src/librados/librados.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librados/librados.cc b/src/librados/librados.cc
index 82721a96aa5..274119c1b28 100644
--- a/src/librados/librados.cc
+++ b/src/librados/librados.cc
@@ -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;