diff options
author | Danny Al-Gaaf <danny.al-gaaf@bisect.de> | 2013-02-08 17:14:19 +0100 |
---|---|---|
committer | Danny Al-Gaaf <danny.al-gaaf@bisect.de> | 2013-02-16 18:39:14 +0100 |
commit | 3de692753c28ddbeb3c86b51466be16e94c9c458 (patch) | |
tree | 05f5aaf458555bcc38f254dea02a60f034b9c599 | |
parent | f19d228c6a49222659c769099aaa4e755b80331d (diff) | |
download | ceph-3de692753c28ddbeb3c86b51466be16e94c9c458.tar.gz |
SyntheticClient.cc: fix some memory leaks in the error handling
Fix some memory leaks in case of error handling due to failed
client->open() calls.
Error from cppcheck was:
[src/client/SyntheticClient.cc:1980]: (error) Memory leak: buf
[src/client/SyntheticClient.cc:2040]: (error) Memory leak: buf
[src/client/SyntheticClient.cc:2090]: (error) Memory leak: buf
(cherry picked from commit f0ba80756d1c3c313014ad7be18191981fb545be)
-rw-r--r-- | src/client/SyntheticClient.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index b2a936f55ac..30e31072f2b 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1977,7 +1977,10 @@ int SyntheticClient::write_file(string& fn, int size, loff_t wrsize) // size i int fd = client->open(fn.c_str(), O_RDWR|O_CREAT); dout(5) << "writing to " << fn << " fd " << fd << dendl; - if (fd < 0) return fd; + if (fd < 0) { + delete[] buf; + return fd; + } utime_t from = ceph_clock_now(g_ceph_context); utime_t start = from; @@ -2037,7 +2040,10 @@ int SyntheticClient::write_fd(int fd, int size, int wrsize) // size is in MB, uint64_t chunks = (uint64_t)size * (uint64_t)(1024*1024) / (uint64_t)wrsize; //dout(5) << "SyntheticClient::write_fd: writing to fd " << fd << dendl; - if (fd < 0) return fd; + if (fd < 0) { + delete[] buf; + return fd; + } for (unsigned i=0; i<chunks; i++) { if (time_to_stop()) { @@ -2087,7 +2093,10 @@ int SyntheticClient::read_file(const std::string& fn, int size, int fd = client->open(fn.c_str(), O_RDONLY); dout(5) << "reading from " << fn << " fd " << fd << dendl; - if (fd < 0) return fd; + if (fd < 0) { + delete[] buf; + return fd; + } utime_t from = ceph_clock_now(g_ceph_context); utime_t start = from; |