[libcxx] r274132 - [libcxx] Fix a bug in strstreambuf::overflow.
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 29 08:26:14 PDT 2016
Author: ahatanak
Date: Wed Jun 29 10:26:13 2016
New Revision: 274132
URL: http://llvm.org/viewvc/llvm-project?rev=274132&view=rev
Log:
[libcxx] Fix a bug in strstreambuf::overflow.
The end pointer should point to one past the end of the newly allocated
buffer.
rdar://problem/24265174
Differential Revision: http://reviews.llvm.org/D20334
Added:
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
Modified:
libcxx/trunk/src/strstream.cpp
Modified: libcxx/trunk/src/strstream.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/strstream.cpp?rev=274132&r1=274131&r2=274132&view=diff
==============================================================================
--- libcxx/trunk/src/strstream.cpp (original)
+++ libcxx/trunk/src/strstream.cpp Wed Jun 29 10:26:13 2016
@@ -175,7 +175,6 @@ strstreambuf::overflow(int_type __c)
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_)
@@ -184,7 +183,7 @@ strstreambuf::overflow(int_type __c)
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;
}
Added: libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp?rev=274132&view=auto
==============================================================================
--- libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp (added)
+++ libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp Wed Jun 29 10:26:13 2016
@@ -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;
+}
More information about the cfe-commits
mailing list