From: xiexingguo <258156334@qq.com> Date: Mon, 26 Oct 2015 10:38:01 +0000 (+0800) Subject: FileStore: potential memory leak if _fgetattrs fails X-Git-Tag: v0.94.6~63^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F6420%2Fhead;p=ceph.git FileStore: potential memory leak if _fgetattrs fails Memory leak happens if _fgetattrs encounters some error and simply returns. Fixes: #13597 Signed-off-by: xie xingguo (cherry picked from commit ace7dd096b58a88e25ce16f011aed09269f2a2b4) --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index f6c3bb872a2e..4f0772e9b646 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -3780,6 +3780,7 @@ int FileStore::_fgetattrs(int fd, map& aset) dout(10) << " -ERANGE, got " << len << dendl; if (len < 0) { assert(!m_filestore_fail_eio || len != -EIO); + delete[] names2; return len; } name = names2; @@ -3798,8 +3799,10 @@ int FileStore::_fgetattrs(int fd, map& 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;