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>
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) {
r = 0;
out:
+ if (buf)
+ delete[] buf;
::close(fd);
return r;
}