[PATCH] D111706: [lld-macho] Fix dangling string reference when adding frameworks

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 19 12:12:42 PDT 2021


int3 added inline comments.


================
Comment at: lld/MachO/Driver.cpp:116
 
-    if (Optional<std::string> path = resolveDylibPath(symlink))
+    if (Optional<StringRef> path = resolveDylibPath(symlink))
       return path;
----------------
int3 wrote:
> oontvoo wrote:
> > I think this could be `resolveDylibPath(saver.save(symlink.str())`
> > 
> > Then in resolveDylibPath (ie., DriverUtils.cpp:line 199), you don't save the StringRef  because the assumption is that when you see a StringRef, it's already been saved.
> That seems really iffy; `resolveDylibPath` should return a safely-allocated StringRef regardless of how it's being called. Better to `save()` twice than to accidentally return an unsaved string.
maybe you didn't see this comment :) I would prefer we revert to calling `saver.save()` within `resolveDylibPath`


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

https://reviews.llvm.org/D111706



More information about the llvm-commits mailing list