stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (STDCXX-514) basic_stringbuf<>::str() deallocating external buffer
Date Thu, 09 Aug 2007 14:37:43 GMT

     [ https://issues.apache.org/jira/browse/STDCXX-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Farid Zaripov resolved STDCXX-514.
----------------------------------

    Resolution: Fixed

Fixed thus: http://svn.apache.org/viewvc?view=rev&rev=564213

> 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.


Mime
View raw message