[Python-checkins] gh-95041: Fail syslog.syslog in case inner call to syslog.openlog fails (GH-95264)

miss-islington webhook-mailer at python.org
Wed Jul 27 06:32:24 EDT 2022


https://github.com/python/cpython/commit/9640c4c88cb3b0dfef88d5a00daa3a02eff6347d
commit: 9640c4c88cb3b0dfef88d5a00daa3a02eff6347d
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-07-27T03:32:02-07:00
summary:

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 <noam at noam.me>

files:
M Modules/syslogmodule.c

diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index 27b176aeb6dba..c409fe968f889 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;
         }
     }
 



More information about the Python-checkins mailing list