[PATCH] D68862: [ARM] Allocatable Global Register Variables for ARM

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 06:03:49 PDT 2019


chill added inline comments.


================
Comment at: clang/lib/Basic/Targets/ARM.cpp:902
+  std::vector<std::string> &Features = getTargetOpts().Features;
+  std::string SearchFeature = "+reserve-" + RegName.str();
+  for (std::string &Feature : Features) {
----------------
SjoerdMeijer wrote:
> I was pointed at something similar myself recently, but if I am not mistaken then I think this is a use-after-free:
> 
>    "+reserve-" + RegName.str()
> 
> this will allocate a temp `std::string` that `SearchFeature` points to, which then gets released, and `SearchFeature` is still pointing at it.
Any temporaries would be destructed at the end of the full expression. By that time, the `SearchString` would be constructed and stand on its own.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68862





More information about the llvm-commits mailing list