Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hammer: osd: FileStore: potential memory leak if getattrs fails. #6420

Merged
1 commit merged into from Nov 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/os/FileStore.cc
Expand Up @@ -3780,6 +3780,7 @@ int FileStore::_fgetattrs(int fd, map<string,bufferptr>& aset)
dout(10) << " -ERANGE, got " << len << dendl;
if (len < 0) {
assert(!m_filestore_fail_eio || len != -EIO);
delete[] names2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be it's better to use std::unique_ptr to avoid the same issue if code changes?

return len;
}
name = names2;
Expand All @@ -3798,8 +3799,10 @@ int FileStore::_fgetattrs(int fd, map<string,bufferptr>& aset)
if (*name) {
dout(20) << "fgetattrs " << fd << " getting '" << name << "'" << dendl;
int r = _fgetattr(fd, attrname, aset[name]);
if (r < 0)
if (r < 0) {
delete[] names2;
return r;
}
}
}
name += strlen(name) + 1;
Expand Down