[PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 28 17:59:02 PDT 2016


I agree with Ben that this looks good.

Marshall and Eric, do you want Akira to hold off, or are you happy deferring to Ben and me?

> On 2016-May-26, at 18:31, Akira Hatanaka via cfe-commits <cfe-commits at lists.llvm.org> wrote:
> 
> ahatanak updated this revision to Diff 58740.
> ahatanak added a comment.
> 
> Remove unused variable and add test case.
> 
> 
> http://reviews.llvm.org/D20334
> 
> Files:
>  src/strstream.cpp
>  test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
> 
> Index: test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/overflow.pass.cpp
> ===================================================================
> --- /dev/null
> +++ 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: src/strstream.cpp
> ===================================================================
> --- src/strstream.cpp
> +++ src/strstream.cpp
> @@ -171,16 +171,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;
>     }
> 
> 
> <D20334.58740.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list