Fznamznon added a comment.

In D146412#4220021 <https://reviews.llvm.org/D146412#4220021>, @kastiglione 
wrote:

> I understand the potential for a use after free, since `OutputStream` is a 
> raw pointer, but I don't understand the fix.

Okay, probably commit message is a little confusing. The potential for a use 
after free is that `OutputStream` is a raw pointer as you already noted, but it 
is also accessible outside of `DumpModuleInfoAction::ExecuteAction`. Before the 
patch there was the case where result of local unique_ptr::get was saved there. 
When the function is exited, unique_ptr frees the memory it did hold, making 
`OutputStream` poiniting to freed memory. Since it can be easily accessed 
outside of `DumpModuleInfoAction::ExecuteAction` hence the potential for 
use-after-free. I wasn't sure if assigning `nullptr` to `OutputStream` at the 
end of `DumpModuleInfoAction::ExecuteAction` was a good idea, so I just added 
code avoiding saving result of unique_ptr::get to `OutputStream` .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146412

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to