]> granicus.if.org Git - python/commitdiff
Merged revisions 75367 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Tue, 27 Oct 2009 12:56:06 +0000 (12:56 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Tue, 27 Oct 2009 12:56:06 +0000 (12:56 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75367 | antoine.pitrou | 2009-10-11 23:03:26 +0200 (dim., 11 oct. 2009) | 4 lines

  Issue #7084: Fix a (very unlikely) crash when printing a list from one
  thread, and mutating it from another one.  Patch by Scott Dial.
........

Misc/ACKS
Misc/NEWS
Objects/listobject.c

index f6433f707d5ff4b87af61215d7fc69b4b463bd17..dbe495b08483b76937bac99b41bc17769d7660a8 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -167,6 +167,7 @@ Arnaud Delobelle
 Erik Demaine
 Roger Dev
 Raghuram Devarakonda
+Scott Dial
 Toby Dickenson
 Mark Dickinson
 Daniel Diniz
index 135d0a2310a7f0e8df34352e531afb3047cfaa6a..aaac9ef0d78c5d7a599460c0d2bd9c8690f7244e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -16,6 +16,9 @@ Core and Builtins
   fixes the problem of some exceptions being thrown at shutdown when the
   interpreter is killed. Patch by Adam Olsen.
 
+- Issue #7084: Fix a (very unlikely) crash when printing a list from one
+  thread, and mutating it from another one.  Patch by Scott Dial.
+
 Library
 -------
 
index 98d7e473549e0a2c557a0754fc0ea64ac38fbf3a..c5b147580292c55ccca97509d3f0b23482c3303c 100644 (file)
@@ -319,6 +319,7 @@ list_print(PyListObject *op, FILE *fp, int flags)
 {
        int rc;
        Py_ssize_t i;
+       PyObject *item;
 
        rc = Py_ReprEnter((PyObject*)op);
        if (rc != 0) {
@@ -333,15 +334,19 @@ list_print(PyListObject *op, FILE *fp, int flags)
        fprintf(fp, "[");
        Py_END_ALLOW_THREADS
        for (i = 0; i < Py_SIZE(op); i++) {
+               item = op->ob_item[i];
+               Py_INCREF(item);
                if (i > 0) {
                        Py_BEGIN_ALLOW_THREADS
                        fprintf(fp, ", ");
                        Py_END_ALLOW_THREADS
                }
-               if (PyObject_Print(op->ob_item[i], fp, 0) != 0) {
+               if (PyObject_Print(item, fp, 0) != 0) {
+                       Py_DECREF(item);
                        Py_ReprLeave((PyObject *)op);
                        return -1;
                }
+               Py_DECREF(item);
        }
        Py_BEGIN_ALLOW_THREADS
        fprintf(fp, "]");