[PATCH] D112130: [clangd] Fix use-after-free in HeaderIncluderCache

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 20 06:32:26 PDT 2021


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/TUScheduler.cpp:294
       invalidate(First);
+    // MainToFirst entry should stay alive, as Associations might be pointing at
+    // its key.
----------------
Hmm, this leaves MainToFirst pointing to an invalidated entry.
Would it make more sense to just null out the value (i.e. First here)?

Then I think we need no code changes elsewhere, as update() already checks if First already exists before invalidating.

(This special case would occur on a rarer path, but the real reason for my preference is that I think the data structure is easier to interpret)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112130/new/

https://reviews.llvm.org/D112130



More information about the cfe-commits mailing list