]> granicus.if.org Git - python/commitdiff
SF bug #1086555: refcount problem in syslog
authorRaymond Hettinger <python@rcn.com>
Thu, 16 Dec 2004 23:52:04 +0000 (23:52 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 16 Dec 2004 23:52:04 +0000 (23:52 +0000)
Modules/syslogmodule.c

index 75deb1b8d7c7214f218c4684da2c97d19586bf98..1f2b874fdbe0f92db408a750fb0667725b6fe741 100644 (file)
@@ -57,17 +57,18 @@ syslog_openlog(PyObject * self, PyObject * args)
 {
        long logopt = 0;
        long facility = LOG_USER;
+       PyObject *new_S_ident_o;
 
-
-       Py_XDECREF(S_ident_o);
        if (!PyArg_ParseTuple(args,
                              "S|ll;ident string [, logoption [, facility]]",
-                             &S_ident_o, &logopt, &facility))
+                             &new_S_ident_o, &logopt, &facility))
                return NULL;
 
        /* This is needed because openlog() does NOT make a copy
         * and syslog() later uses it.. cannot trash it.
         */
+       Py_XDECREF(S_ident_o);
+       S_ident_o = new_S_ident_o;
        Py_INCREF(S_ident_o);
 
        openlog(PyString_AsString(S_ident_o), logopt, facility);