mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Add belt and braces check of PyString_AsString return.
This commit is contained in:
parent
1b6f398c98
commit
cf0fd5ab29
1 changed files with 5 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue