Visitar URL original
gh-95041: Fix several minor issues in syslog.openlog() by serhiy-storchaka · Pull Request #95058 · python/cpython · GitHub
Skip to content
Merged
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
Fix the remaining issue:
* Possible use of freed memory if syslog.openlog() is called while
  the GIL is released in syslog.syslog().
  • Loading branch information
serhiy-storchaka committed Jul 25, 2022
commit 7e5a375dc41fae630aaf5be08495feb21a11d265
6 changes: 6 additions & 0 deletions Modules/syslogmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,15 @@ syslog_syslog(PyObject * self, PyObject * args)
}
}

/* Incref ident, because it can be decrefed if syslog.openlog() is
* called when the GIL is released.
*/
PyObject *ident = S_ident_o;
Py_XINCREF(ident);
Py_BEGIN_ALLOW_THREADS;
syslog(priority, "%s", message);
Py_END_ALLOW_THREADS;
Py_XDECREF(ident);
Py_RETURN_NONE;
}

Expand Down