]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: fix clang static check warn use-after-free 12581/head
authorliuchang0812 <liuchang0812@gmail.com>
Tue, 20 Dec 2016 05:21:40 +0000 (13:21 +0800)
committerliuchang0812 <liuchang0812@gmail.com>
Tue, 20 Dec 2016 05:21:40 +0000 (13:21 +0800)
Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
src/os/filestore/FileStore.cc

index df0c63b89f98745980ba36745fe2c016e7b02c7c..cc3bab89fab98ea34017e76724f664a0620522e2 100644 (file)
@@ -3212,13 +3212,16 @@ more:
     last = extent++;
   }
   const bool is_last = last->fe_flags & FIEMAP_EXTENT_LAST;
-  free(fiemap);
   if (!is_last) {
     uint64_t xoffset = last->fe_logical + last->fe_length - offset;
     offset = last->fe_logical + last->fe_length;
     len -= xoffset;
+    free(fiemap); /* fix clang warn: use-after-free */
     goto more;
   }
+  else {
+    free(fiemap);
+  }
 
   return r;
 }