Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-40077: Update
  • Loading branch information
corona10 committed Jun 19, 2020
commit dbc4d329128cfc59f713ca7eebbe51c574c1a8be
7 changes: 3 additions & 4 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,7 @@ parse_add_char(ReaderObj *self, Py_UCS4 c)
{
PyTypeObject *reader_type = Py_TYPE(self);
_csvstate *state = PyType_GetModuleState(reader_type);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Reader type has Py_TPFLAGS_BASETYPE: PyType_GetModuleState() is unsafe here.

if (state == NULL) {
return -1;
}
assert(state != NULL);
if (self->field_len >= state->field_limit) {
PyErr_Format(state->error_obj, "field larger than field limit (%ld)",
state->field_limit);
Expand All @@ -589,6 +587,7 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
DialectObj *dialect = self->dialect;
PyTypeObject *reader_type = Py_TYPE(self);
_csvstate *state = PyType_GetModuleState(reader_type);
assert(state != NULL);
switch (self->state) {
case START_RECORD:
/* start of record */
Expand Down Expand Up @@ -788,7 +787,7 @@ Reader_iternext(ReaderObj *self)
PyObject *lineobj;
PyTypeObject* reader_type = Py_TYPE(self);
_csvstate *state = PyType_GetModuleState(reader_type);

assert(state != NULL);
if (parse_reset(self) < 0)
return NULL;
do {
Expand Down