diff options
author | Danny Al-Gaaf <danny.al-gaaf@bisect.de> | 2013-05-13 14:15:04 +0200 |
---|---|---|
committer | Danny Al-Gaaf <danny.al-gaaf@bisect.de> | 2013-05-14 18:39:31 +0200 |
commit | eac545e12cff6203bc46e77142bb1be2f466bf9c (patch) | |
tree | f650553287555a90ca747ac54606a9e959c89409 | |
parent | c3c140b38ce1a5a5ad5e316c50707f68e6bfe2ab (diff) | |
download | ceph-eac545e12cff6203bc46e77142bb1be2f466bf9c.tar.gz |
tools/ceph.cc: cleanup memory allocated for 'buf'
CID 717123 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "buf" going out of scope leaks the storage
it points to.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
-rw-r--r-- | src/tools/ceph.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/tools/ceph.cc b/src/tools/ceph.cc index fd4dbb17d7b..b0cf91a5341 100644 --- a/src/tools/ceph.cc +++ b/src/tools/ceph.cc @@ -232,11 +232,11 @@ int do_admin_socket(string path, string cmd) if (connect(fd, (struct sockaddr *) &address, sizeof(struct sockaddr_un)) != 0) { cerr << "connect to " << path << " failed with " << cpp_strerror(errno) << std::endl; - r = -1; - goto out; + ::close(fd); + return -1; } - char *buf; + char *buf = NULL; uint32_t len; r = safe_write(fd, cmd.c_str(), cmd.length() + 1); if (r < 0) { @@ -268,6 +268,8 @@ int do_admin_socket(string path, string cmd) r = 0; out: + if (buf) + delete[] buf; ::close(fd); return r; } |