]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport fixes for bugs #1086555 and #1085744.
authorRaymond Hettinger <python@rcn.com>
Fri, 17 Dec 2004 14:44:45 +0000 (14:44 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 17 Dec 2004 14:44:45 +0000 (14:44 +0000)
Misc/NEWS
Modules/syslogmodule.c
Objects/abstract.c

index 01d157cb403890344d9aab414ad32d3769aacf75..c5bf2b8f11f57649c15f7a74b35b86b56a96223a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,11 @@ What's New in Python 2.4 final?
 Core and builtins
 -----------------
 
+- Bug #1086555:  Fix leak in syslog module.
+
+- Bug #1085744:  Add missing overflow check to PySequence_Tuple().
+  Make resize schedule linear (amortized).
+
 - Bug 875692: Improve signal handling, especially when using threads, by
   forcing an early re-execution of PyEval_EvalFrame() "periodic" code when
   things_to_do is not cleared by Py_MakePendingCalls().
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);
index 377f359300d3e719a2f95d0032d935326b22e3b6..9c1b68b8383e0e8d5f92a5f4b0f383bb5de4fdc6 100644 (file)
@@ -1427,10 +1427,15 @@ PySequence_Tuple(PyObject *v)
                        break;
                }
                if (j >= n) {
-                       if (n < 500)
-                               n += 10;
-                       else
-                               n += 100;
+                       int oldn = n;
+                       n += 10;
+                       n += n >> 2;
+                       if (n < oldn) {
+                               /* Check for overflow */
+                               PyErr_NoMemory();
+                               Py_DECREF(item);
+                               goto Fail; 
+                       }
                        if (_PyTuple_Resize(&result, n) != 0) {
                                Py_DECREF(item);
                                goto Fail;