]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95041: Fail syslog.syslog in case inner call to syslog.openlog fails (GH-95264)
authorNoam Cohen <noam@noam.me>
Tue, 26 Jul 2022 11:34:15 +0000 (14:34 +0300)
committerGitHub <noreply@github.com>
Tue, 26 Jul 2022 11:34:15 +0000 (14:34 +0300)
Modules/syslogmodule.c

index 27b176aeb6dba7593ffcd256e0a3356a5b51e3f2..c409fe968f8894a6337092ff9ba2eb458ade5f8a 100644 (file)
@@ -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;
         }
     }