summaryrefslogtreecommitdiff
path: root/pyfstream.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-02-15 10:53:29 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:02 -0400
commit7eafc0d9cad27ac74db529b7eab360e5950835eb (patch)
treeb642f107824d504669dac95c7d8c3a0893ff3fc6 /pyfstream.h
parentfa8f20884b6c82831b6f8c1c2b7adc80114d5ac6 (diff)
downloadfork-ledger-7eafc0d9cad27ac74db529b7eab360e5950835eb.tar.gz
fork-ledger-7eafc0d9cad27ac74db529b7eab360e5950835eb.tar.bz2
fork-ledger-7eafc0d9cad27ac74db529b7eab360e5950835eb.zip
bug fix
Diffstat (limited to 'pyfstream.h')
-rw-r--r--pyfstream.h8
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;
}
};