I've got a memory corruption when I try to write more than 1000 bytes at once.
vagrant@gitlab:~$ ./a.out
*** Error in `./a.out': free(): invalid next size (normal): 0x0000000001677400 ***
A snippet of code which highlights the bug:
#include <iostream>
#include <nnxx/message.h>
#include <nnxx/message_ostream.h>
int main()
{
std::string str(2000, 'A');
nnxx::message_ostream os;
os << str;
}
It turned out that the copy made by message_streambuf::xsputn does not take into account the available buffer size. Thereby the writes with a size higher than 1000 are not handled correctly.
Hello,
I've got a memory corruption when I try to write more than 1000 bytes at once.
A snippet of code which highlights the bug:
It turned out that the copy made by message_streambuf::xsputn does not take into account the available buffer size. Thereby the writes with a size higher than 1000 are not handled correctly.
I follow the libstd++'s implementation of steambuf::xsputn to provide this patch.
Test results: