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

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 20 06:02:21 PDT 2018


hokein added inline comments.


================
Comment at: lib/Support/StringSaver.cpp:14
 
 StringRef StringSaver::save(StringRef S) {
+  if (S.empty())
----------------
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D50966





More information about the cfe-commits mailing list