[Python-checkins] cpython: Issue #22206: Using pthread, PyThread_create_key() now sets errno to ENOMEM and
victor.stinner
python-checkins at python.org
Sun Aug 17 22:14:06 CEST 2014
http://hg.python.org/cpython/rev/1b898b5d5ffe
changeset: 92143:1b898b5d5ffe
user: Victor Stinner <victor.stinner at gmail.com>
date: Sun Aug 17 22:11:06 2014 +0200
summary:
Issue #22206: Using pthread, PyThread_create_key() now sets errno to ENOMEM and
returns -1 (error) on integer overflow.
files:
Misc/NEWS | 3 +++
Python/thread_pthread.h | 10 +++++++++-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #22206: Using pthread, PyThread_create_key() now sets errno to ENOMEM
+ and returns -1 (error) on integer overflow.
+
- Issue #20184: Argument Clinic based signature introspection added for
30 of the builtin functions.
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -608,7 +608,15 @@
{
pthread_key_t key;
int fail = pthread_key_create(&key, NULL);
- return fail ? -1 : key;
+ if (fail)
+ return -1;
+ if (key > INT_MAX) {
+ /* Issue #22206: handle integer overflow */
+ pthread_key_delete(key);
+ errno = ENOMEM;
+ return -1;
+ }
+ return (int)key;
}
void
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list