mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +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)
|
join_append_lineterminator(WriterObj *self)
|
||||||
{
|
{
|
||||||
int terminator_len;
|
int terminator_len;
|
||||||
|
char *terminator;
|
||||||
|
|
||||||
terminator_len = PyString_Size(self->dialect->lineterminator);
|
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))
|
if (!join_check_rec_size(self, self->rec_len + terminator_len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memmove(self->rec + self->rec_len,
|
terminator = PyString_AsString(self->dialect->lineterminator);
|
||||||
/* should not be NULL */
|
if (terminator == NULL)
|
||||||
PyString_AsString(self->dialect->lineterminator),
|
return 0;
|
||||||
terminator_len);
|
memmove(self->rec + self->rec_len, terminator, terminator_len);
|
||||||
self->rec_len += terminator_len;
|
self->rec_len += terminator_len;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue