diff options
author | Andrew McNamara <andrewm@object-craft.com.au> | 2005-01-12 01:16:35 (GMT) |
---|---|---|
committer | Andrew McNamara <andrewm@object-craft.com.au> | 2005-01-12 01:16:35 (GMT) |
commit | cf0fd5ab2944eac38c2cd9c0904b24fd8e30e32f (patch) | |
tree | 12aa549f89f0648c897725efd4f4a77661404691 | |
parent | 1b6f398c987f3078fc7732e1935e12c6b3712027 (diff) | |
download | cpython-cf0fd5ab2944eac38c2cd9c0904b24fd8e30e32f.zip cpython-cf0fd5ab2944eac38c2cd9c0904b24fd8e30e32f.tar.gz cpython-cf0fd5ab2944eac38c2cd9c0904b24fd8e30e32f.tar.bz2 |
Add belt and braces check of PyString_AsString return.
-rw-r--r-- | Modules/_csv.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index 03e715a..a433960 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -1098,6 +1098,7 @@ static int join_append_lineterminator(WriterObj *self) { int terminator_len; + char *terminator; terminator_len = PyString_Size(self->dialect->lineterminator); @@ -1105,10 +1106,10 @@ join_append_lineterminator(WriterObj *self) if (!join_check_rec_size(self, self->rec_len + terminator_len)) return 0; - memmove(self->rec + self->rec_len, - /* should not be NULL */ - PyString_AsString(self->dialect->lineterminator), - terminator_len); + terminator = PyString_AsString(self->dialect->lineterminator); + if (terminator == NULL) + return 0; + memmove(self->rec + self->rec_len, terminator, terminator_len); self->rec_len += terminator_len; return 1; |