[libcxx-commits] [PATCH] D154499: [libc++] Do not use stringbuf's string after move

Piotr Fusik via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 5 05:13:11 PDT 2023


pfusik created this revision.
Herald added a project: All.
pfusik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154499

Files:
  libcxx/include/sstream


Index: libcxx/include/sstream
===================================================================
--- libcxx/include/sstream
+++ libcxx/include/sstream
@@ -420,10 +420,9 @@
         this->__pbump(__nout);
     }
     __hm_ = __hm == -1 ? nullptr : __p + __hm;
-    __p = const_cast<char_type*>(__rhs.__str_.data());
-    __rhs.setg(__p, __p, __p);
-    __rhs.setp(__p, __p);
-    __rhs.__hm_ = __p;
+    __rhs.setg(nullptr, nullptr, nullptr);
+    __rhs.setp(nullptr, nullptr);
+    __rhs.__hm_ = nullptr;
     this->pubimbue(__rhs.getloc());
 }
 
@@ -467,10 +466,9 @@
 
     __hm_ = __hm == -1 ? nullptr : __p + __hm;
     __mode_ = __rhs.__mode_;
-    __p = const_cast<char_type*>(__rhs.__str_.data());
-    __rhs.setg(__p, __p, __p);
-    __rhs.setp(__p, __p);
-    __rhs.__hm_ = __p;
+    __rhs.setg(nullptr, nullptr, nullptr);
+    __rhs.setp(nullptr, nullptr);
+    __rhs.__hm_ = nullptr;
     this->pubimbue(__rhs.getloc());
     return *this;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154499.537307.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230705/29869fe1/attachment.bin>


More information about the libcxx-commits mailing list