aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-08-17 22:11:06 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-08-17 22:11:06 +0200
commitdaca3d7e9b48badf02521df1b729ddd2733b2d77 (patch)
tree69c02529bc45711417bc5d3883d39732cd65af76 /Python/thread_pthread.h
parent_pickle: Optimize raw_unicode_escape(), use directly a bytes object, don't use (diff)
downloadcpython-daca3d7e9b48badf02521df1b729ddd2733b2d77.tar.gz
cpython-daca3d7e9b48badf02521df1b729ddd2733b2d77.tar.bz2
cpython-daca3d7e9b48badf02521df1b729ddd2733b2d77.zip
Issue #22206: Using pthread, PyThread_create_key() now sets errno to ENOMEM and
returns -1 (error) on integer overflow.
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r--Python/thread_pthread.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index d9f7c76f2ab..27e0dc84bcb 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -608,7 +608,15 @@ PyThread_create_key(void)
{
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