[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 6 08:38:30 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 9e9404387d3b787305dc8bf21b0e20c477b6ff39 dd36ef6dd52f57d175fd60534172f0e28e11ef48 -- clang/lib/InstallAPI/HeaderFile.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/InstallAPI/HeaderFile.cpp b/clang/lib/InstallAPI/HeaderFile.cpp
index f25bf3428e..f6101d6b7c 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,13 +51,13 @@ llvm::Expected<PathSeq> enumerateFiles(FileManager &FM, StringRef Directory) {
     if (EC)
       return errorCodeToError(EC);
 
-    Ensure the iterator is valid before dereferencing.
-    if (i == ie || !i->isValid())
-      break;
+    Ensure the iterator is valid before dereferencing.if (i == ie ||
+                                                          !i->isValid()) break;
 
     // Skip files that do not exist. This usually happens for broken symlinks.
     auto StatusOrErr = FS.status(i->path());
-    if (!StatusOrErr || StatusOrErr.getError() == std::errc::no_such_file_or_directory)
+    if (!StatusOrErr ||
+        StatusOrErr.getError() == std::errc::no_such_file_or_directory)
       continue;
 
     StringRef Path = i->path();

``````````

</details>


https://github.com/llvm/llvm-project/pull/97900


More information about the cfe-commits mailing list