From 5ae3cb1d73d65a1b3a4f6c002e1b20e7d76fd90f Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Tue, 26 Jul 2022 14:34:15 +0300 Subject: [PATCH] gh-95041: Fail syslog.syslog in case inner call to syslog.openlog fails (GH-95264) (cherry picked from commit b1f648efc56ff17e18ec2b7402d59a771b305004) Co-authored-by: Noam Cohen --- Modules/syslogmodule.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c index 27b176aeb6dba7..c409fe968f8894 100644 --- a/Modules/syslogmodule.c +++ b/Modules/syslogmodule.c @@ -191,8 +191,14 @@ syslog_syslog(PyObject * self, PyObject * args) */ if ((openargs = PyTuple_New(0))) { PyObject *openlog_ret = syslog_openlog(self, openargs, NULL); - Py_XDECREF(openlog_ret); Py_DECREF(openargs); + if (openlog_ret == NULL) { + return NULL; + } + Py_DECREF(openlog_ret); + } + else { + return NULL; } }