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
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;
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()) {
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;