From ca47ebf3fce4e3b9f9a29136bcfd77994e8c481e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 3 Jul 2016 21:03:53 +0300 Subject: Issue #23034: The output of a special Python build with defined COUNT_ALLOCS, SHOW_ALLOC_COUNT or SHOW_TRACK_COUNT macros is now off by default. It can be re-enabled using the "-X showalloccount" option. It now outputs to stderr instead of stdout. --- Objects/tupleobject.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Objects/tupleobject.c') diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index a7774e2fd1..1b412580dc 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -36,6 +36,16 @@ static Py_ssize_t count_tracked = 0; static void show_track(void) { + PyObject *xoptions, *value; + _Py_IDENTIFIER(showalloccount); + + xoptions = PySys_GetXOptions(); + if (xoptions == NULL) + return; + value = _PyDict_GetItemId(xoptions, &PyId_showalloccount); + if (value != Py_True) + return; + fprintf(stderr, "Tuples created: %" PY_FORMAT_SIZE_T "d\n", count_tracked + count_untracked); fprintf(stderr, "Tuples tracked by the GC: %" PY_FORMAT_SIZE_T -- cgit v1.2.1 From d668db1ce63db878bfbe6e05ccff9addd3003d64 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Mon, 25 Jul 2016 02:39:20 +0000 Subject: Issue #1621: Avoid signed overflow in list and tuple operations Patch by Xiang Zhang. --- Objects/tupleobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Objects/tupleobject.c') diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 1b412580dc..c0ff499e72 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -453,9 +453,9 @@ tupleconcat(PyTupleObject *a, PyObject *bb) return NULL; } #define b ((PyTupleObject *)bb) - size = Py_SIZE(a) + Py_SIZE(b); - if (size < 0) + if (Py_SIZE(a) > PY_SSIZE_T_MAX - Py_SIZE(b)) return PyErr_NoMemory(); + size = Py_SIZE(a) + Py_SIZE(b); np = (PyTupleObject *) PyTuple_New(size); if (np == NULL) { return NULL; -- cgit v1.2.1