[compiler-rt] 17718a2 - Move close() to the proper else block

Shivam Gupta via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 05:45:59 PST 2023


Author: Wu, Yingcong
Date: 2023-03-01T19:09:11+05:30
New Revision: 17718a2cff7d4e09811260dfcb0577b82bf3fe7f

URL: https://github.com/llvm/llvm-project/commit/17718a2cff7d4e09811260dfcb0577b82bf3fe7f
DIFF: https://github.com/llvm/llvm-project/commit/17718a2cff7d4e09811260dfcb0577b82bf3fe7f.diff

LOG: Move close() to the proper else block

`LogWriter::Close(LW)` is outside the null check if-else block, which, when `LW == nullptr`, will causing a NULL dereference.
I think the close() means to be in else block, which is when `LW != nullptr`.

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D145039

Added: 
    

Modified: 
    compiler-rt/lib/xray/xray_profiling.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/xray/xray_profiling.cpp b/compiler-rt/lib/xray/xray_profiling.cpp
index 81c33fae88c1f..259ec65a76a1f 100644
--- a/compiler-rt/lib/xray/xray_profiling.cpp
+++ b/compiler-rt/lib/xray/xray_profiling.cpp
@@ -253,8 +253,8 @@ XRayLogFlushStatus profilingFlush() XRAY_NEVER_INSTRUMENT {
                        reinterpret_cast<const char *>(B.Data) + B.Size);
           B = profileCollectorService::nextBuffer(B);
         }
+        LogWriter::Close(LW);
       }
-      LogWriter::Close(LW);
     }
   }
 


        


More information about the llvm-commits mailing list