[Python-checkins] cpython (3.5): Issue #14373: Fixed segmentation fault when gc.collect() is called during
serhiy.storchaka
python-checkins at python.org
Sat Jul 25 11:11:37 CEST 2015
https://hg.python.org/cpython/rev/5345e5ce2eed
changeset: 97053:5345e5ce2eed
branch: 3.5
parent: 97050:6888979cd407
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Jul 25 12:10:21 2015 +0300
summary:
Issue #14373: Fixed segmentation fault when gc.collect() is called during
constructing lru_cache (C implementation).
files:
Misc/NEWS | 3 +++
Modules/_functoolsmodule.c | 11 ++++++-----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -28,6 +28,9 @@
Library
-------
+- Issue #14373: Fixed segmentation fault when gc.collect() is called during
+ constructing lru_cache (C implementation).
+
- Issue #24695: Fix a regression in traceback.print_exception(). If
exc_traceback is None we shouldn't print a traceback header like described
in the documentation.
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -899,7 +899,7 @@
static PyObject *
lru_cache_new(PyTypeObject *type, PyObject *args, PyObject *kw)
{
- PyObject *func, *maxsize_O, *cache_info_type;
+ PyObject *func, *maxsize_O, *cache_info_type, *cachedict;
int typed;
lru_cache_object *obj;
Py_ssize_t maxsize;
@@ -937,15 +937,16 @@
return NULL;
}
- obj = (lru_cache_object *)type->tp_alloc(type, 0);
- if (obj == NULL)
+ if (!(cachedict = PyDict_New()))
return NULL;
- if (!(obj->cache = PyDict_New())) {
- Py_DECREF(obj);
+ obj = (lru_cache_object *)type->tp_alloc(type, 0);
+ if (obj == NULL) {
+ Py_DECREF(cachedict);
return NULL;
}
+ obj->cache = cachedict;
obj->root.prev = &obj->root;
obj->root.next = &obj->root;
obj->maxsize = maxsize;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list