diff options
author | John Wiegley <johnw@newartisans.com> | 2005-02-15 10:53:29 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:02 -0400 |
commit | 7eafc0d9cad27ac74db529b7eab360e5950835eb (patch) | |
tree | b642f107824d504669dac95c7d8c3a0893ff3fc6 /pyfstream.h | |
parent | fa8f20884b6c82831b6f8c1c2b7adc80114d5ac6 (diff) | |
download | fork-ledger-7eafc0d9cad27ac74db529b7eab360e5950835eb.tar.gz fork-ledger-7eafc0d9cad27ac74db529b7eab360e5950835eb.tar.bz2 fork-ledger-7eafc0d9cad27ac74db529b7eab360e5950835eb.zip |
bug fix
Diffstat (limited to 'pyfstream.h')
-rw-r--r-- | pyfstream.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pyfstream.h b/pyfstream.h index e10b5bd5..c41940f5 100644 --- a/pyfstream.h +++ b/pyfstream.h @@ -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; } }; |