Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix memory leaks during interpreter startup when a path configuration file is
empty or too large, or when an audit hook rejects a command.
2 changes: 2 additions & 0 deletions Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,11 @@ getpath_readlines_impl(PyObject *module, PyObject *pathobj)
size_t cb = fread(buffer, 1, MAX_FILE, fp);
fclose(fp);
if (!cb) {
PyMem_Free(buffer);
return r;
}
if (cb >= MAX_FILE) {
PyMem_Free(buffer);
Py_DECREF(r);
PyErr_SetString(PyExc_MemoryError,
"cannot read file larger than 32KB during initialization");
Expand Down
1 change: 1 addition & 0 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ pymain_run_command(wchar_t *command)
}

if (PySys_Audit("cpython.run_command", "O", unicode) < 0) {
Py_DECREF(unicode);
return pymain_exit_err_print();
}

Expand Down
Loading