From 1d359455b3dd6abb383542ba596a03f14ac54dbd Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Tue, 20 Dec 2016 13:21:40 +0800 Subject: [PATCH] os/filestore: fix clang static check warn use-after-free Signed-off-by: liuchang0812 --- src/os/filestore/FileStore.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index df0c63b89f987..cc3bab89fab98 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -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; } -- 2.39.5