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

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 20 07:36:19 PDT 2021


kadircet marked an inline comment as done.
kadircet added inline comments.


================
Comment at: clang-tools-extra/clangd/TUScheduler.cpp:294
       invalidate(First);
+    // MainToFirst entry should stay alive, as Associations might be pointing at
+    // its key.
----------------
sammccall wrote:
> 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)
Thanks! Yeah that makes sense + now there's a point for `First` being a reference :P


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