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

Sjoerd Meijer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 11 06:22:14 PDT 2019


SjoerdMeijer 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) {
----------------
chill wrote:
> 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.
Ah yes, true. This is a std::string, not stringref as in my case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68862





More information about the cfe-commits mailing list