You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2007/08/09 16:45:43 UTC
[jira] Closed: (STDCXX-514) basic_stringbuf<>::str() deallocating
external buffer
[ https://issues.apache.org/jira/browse/STDCXX-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov closed STDCXX-514.
--------------------------------
The regression test added: http://svn.apache.org/viewvc?view=rev&rev=564228
> basic_stringbuf<>::str() deallocating external buffer
> -----------------------------------------------------
>
> Key: STDCXX-514
> URL: https://issues.apache.org/jira/browse/STDCXX-514
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 27. Input/Output
> Affects Versions: 4.1.3
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Fix For: 4.2
>
>
> The program below aborts due to deallocating the external buffer extbuf.
> test.cpp:
> ------------------
> #include <sstream> // for stringbuf
> #include <memory> // for allocator
> #include <cassert> // for assert()
> char extbuf [3];
> struct MyAlloc : std::allocator <char>
> {
> pointer allocate (size_type __n, std::allocator<void>::const_pointer = 0) {
> return new char [__n];
> }
> void deallocate (pointer __p, size_type)
> {
> assert (extbuf != __p);
> delete [] __p;
> }
> };
> int main ()
> {
> std::basic_stringbuf <char, std::char_traits <char>, MyAlloc> sbuf;
> sbuf.pubsetbuf (extbuf, sizeof (extbuf));
> const char* str = "abcdef";
> sbuf.str (str);
> assert (sbuf.str () == str);
> return 0;
> }
> ------------------
> The test output:
> ------------------
> test: test.cpp:16: void MyAlloc::deallocate(char*, unsigned int): Assertion `extbuf != __p' failed.
> Aborted
> ------------------
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.