summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-12-17 14:44:45 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-12-17 14:44:45 (GMT)
commitfe09fa2ff190b4f6ac0724484085459ad83ba1a9 (patch)
tree920889b0961d8ad2c2f6ae418d0e77d28f548fc2
parent19c9a85fea5cc34238cc6863d80e30472118a61c (diff)
downloadcpython-fe09fa2ff190b4f6ac0724484085459ad83ba1a9.zip
cpython-fe09fa2ff190b4f6ac0724484085459ad83ba1a9.tar.gz
cpython-fe09fa2ff190b4f6ac0724484085459ad83ba1a9.tar.bz2
Backport fixes for bugs #1086555 and #1085744.
-rw-r--r--Misc/NEWS5
-rw-r--r--Modules/syslogmodule.c7
-rw-r--r--Objects/abstract.c13
3 files changed, 18 insertions, 7 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 01d157c..c5bf2b8 100644
--- 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().
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index 75deb1b..1f2b874 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -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);
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 377f359..9c1b68b 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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;