From 93cd26e5862744a877594ae0d804b569de227225 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 17 Aug 2014 22:11:06 +0200 Subject: Issue #22206: Using pthread, PyThread_create_key() now sets errno to ENOMEM and returns -1 (error) on integer overflow. --- Python/thread_pthread.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Python/thread_pthread.h') diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index d9f7c76f2a..27e0dc84bc 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 -- cgit v1.2.1