bug fix
This commit is contained in:
parent
fa8f20884b
commit
7eafc0d9ca
1 changed files with 6 additions and 2 deletions
|
|
@ -35,8 +35,12 @@ class pyoutbuf : public std::streambuf {
|
|||
|
||||
// write multiple characters
|
||||
virtual std::streamsize xsputn (const char* s, std::streamsize num) {
|
||||
if (PyFile_WriteString(s, (PyObject *)fo) < 0)
|
||||
return 0;
|
||||
char * buf = new char[num + 1];
|
||||
std::strncpy(buf, s, num);
|
||||
buf[num] = '\0';
|
||||
if (PyFile_WriteString(buf, (PyObject *)fo) < 0)
|
||||
num = 0;
|
||||
delete[] buf;
|
||||
return num;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue