Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
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
26 changes: 19 additions & 7 deletions 26 Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -5858,14 +5858,20 @@ load_extension(UnpicklerObject *self, int nbytes)
/* Since the extension registry is manipulable via Python code,
* confirm that pair is really a 2-tuple of strings.
*/
if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2 ||
!PyUnicode_Check(module_name = PyTuple_GET_ITEM(pair, 0)) ||
!PyUnicode_Check(class_name = PyTuple_GET_ITEM(pair, 1))) {
Py_DECREF(py_code);
PyErr_Format(PyExc_ValueError, "_inverted_registry[%ld] "
"isn't a 2-tuple of strings", code);
return -1;
if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2) {
goto error;
}

module_name = PyTuple_GET_ITEM(pair, 0);
if (!PyUnicode_Check(module_name)) {
goto error;
}

class_name = PyTuple_GET_ITEM(pair, 1);
if (!PyUnicode_Check(class_name)) {
goto error;
}

/* Load the object. */
obj = find_class(self, module_name, class_name);
if (obj == NULL) {
Expand All @@ -5881,6 +5887,12 @@ load_extension(UnpicklerObject *self, int nbytes)
}
PDATA_PUSH(self->stack, obj, -1);
return 0;

error:
Py_DECREF(py_code);
PyErr_Format(PyExc_ValueError, "_inverted_registry[%ld] "
"isn't a 2-tuple of strings", code);
return -1;
}

static int
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.