[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 30 07:38:15 PDT 2024
================
@@ -51,8 +51,14 @@ llvm::Expected<PathSeq> enumerateFiles(FileManager &FM, StringRef Directory) {
if (EC)
return errorCodeToError(EC);
+ // Ensure the iterator is valid before dereferencing.
+ if (i == ie)
----------------
smanna12 wrote:
> Why does this make a difference?
Thanks @cyndyishida for reviews!
>>the same check happens at each iteration of the loop on line 50. There's no mutations on `i` or `ie` between there and this check.
Agreed. I misunderstood the codes!
https://github.com/llvm/llvm-project/pull/97900
More information about the cfe-commits
mailing list