[PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 29 08:33:15 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274132: [libcxx] Fix a bug in strstreambuf::overflow. (authored by ahatanak).
Changed prior to commit:
http://reviews.llvm.org/D20334?vs=58740&id=62225#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20334
Files:
libcxx/trunk/src/strstream.cpp
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
Index: libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
===================================================================
--- libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
+++ libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int overflow(int c);
+
+#include <iostream>
+#include <string>
+#include <strstream>
+
+int main(int, char const **argv) {
+ std::ostrstream oss;
+ std::string s;
+
+ for (int i = 0; i < 4096; ++i)
+ s.push_back((i % 16) + 'a');
+
+ oss << s << std::ends;
+ std::cout << oss.str();
+ oss.freeze(false);
+
+ return 0;
+}
Index: libcxx/trunk/src/strstream.cpp
===================================================================
--- libcxx/trunk/src/strstream.cpp
+++ libcxx/trunk/src/strstream.cpp
@@ -175,16 +175,15 @@
ptrdiff_t ninp = gptr() - eback();
ptrdiff_t einp = egptr() - eback();
ptrdiff_t nout = pptr() - pbase();
- ptrdiff_t eout = epptr() - pbase();
if (__strmode_ & __allocated)
{
if (__pfree_)
__pfree_(eback());
else
delete [] eback();
}
setg(buf, buf + ninp, buf + einp);
- setp(buf + einp, buf + einp + eout);
+ setp(buf + einp, buf + new_size);
pbump(static_cast<int>(nout));
__strmode_ |= __allocated;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20334.62225.patch
Type: text/x-patch
Size: 1942 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160629/7147096b/attachment.bin>
More information about the cfe-commits
mailing list