[PATCH] D50966: Fix an undefined behavior when storing an empty StringRef.

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 20 06:09:58 PDT 2018


ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lg



================
Comment at: lib/Support/StringSaver.cpp:14
 
 StringRef StringSaver::save(StringRef S) {
+  if (S.empty())
----------------
hokein wrote:
> ioeric wrote:
> > Is it possible to reuse `StringRef::copy(Allocator &)` here?
> Unfortunately, not, `StringRef::copy` will change the behavior. The `StringRef` returned here is null-terminated.
Hmm, that seems strange but out of the scope.


Repository:
  rL LLVM

https://reviews.llvm.org/D50966





More information about the cfe-commits mailing list