]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95041: Fail syslog.syslog in case inner call to syslog.openlog fails (GH-95264)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 26 Jul 2022 11:56:04 +0000 (04:56 -0700)
committerGitHub <noreply@github.com>
Tue, 26 Jul 2022 11:56:04 +0000 (04:56 -0700)
(cherry picked from commit b1f648efc56ff17e18ec2b7402d59a771b305004)

Co-authored-by: Noam Cohen <noam@noam.me>
Modules/syslogmodule.c

index 95e5effafd58f2dfbff59dacfbeb9343c41d6a2c..729986a5549ef094e147c3da51290c1313dcf042 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;
         }
     }