]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: potential memory leak if _fgetattrs fails 6846/head
authorxiexingguo <258156334@qq.com>
Mon, 26 Oct 2015 10:38:01 +0000 (18:38 +0800)
committerAbhishek Varshney <abhishek.varshney@flipkart.com>
Tue, 8 Dec 2015 08:05:18 +0000 (13:35 +0530)
Memory leak happens if _fgetattrs encounters some error and simply returns.
Fixes: #13597
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit ace7dd096b58a88e25ce16f011aed09269f2a2b4)

src/os/FileStore.cc

index 3e8bb29fcc4e1331141b711c2fd652697a4b614c..78e24a139257086695f1d897d328487c5a8e4fa9 100644 (file)
@@ -3922,6 +3922,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;
       return len;
     }
     name = names2;
@@ -3940,8 +3941,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;