[all-commits] [llvm/llvm-project] 2eb96e: [DebugInfo][NFC] Avoid a use-after-free

Jeremy Morse via All-commits all-commits at lists.llvm.org
Mon Oct 25 06:16:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2eb96e1711bf6ae03351c7ba9d7ce8a40f6aa21c
      https://github.com/llvm/llvm-project/commit/2eb96e1711bf6ae03351c7ba9d7ce8a40f6aa21c
  Author: Jeremy Morse <jeremy.morse at sony.com>
  Date:   2021-10-25 (Mon, 25 Oct 2021)

  Changed paths:
    M llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

  Log Message:
  -----------
  [DebugInfo][NFC] Avoid a use-after-free

This patch swaps two lines -- the CurSucc reference can be invalidated
by the call to DFS.push_back, therefore that should happen last. The
usual hat-tip to asan for catching this.

This patch also swaps an ealier call to ToAdd.insert and DFS.push_back,
where a stable iterator (from successors()) is being used. This isn't
strictly necessary, but is good for consistency and avoiding readers
asking themselves why the two code portions have a different order.




More information about the All-commits mailing list