summaryrefslogtreecommitdiff
path: root/Python/thread_pthread.h
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2014-09-13 23:40:27 -0700
committerNed Deily <nad@acm.org>2014-09-13 23:40:27 -0700
commit4278e8cf357c7418651ca0e23346b2ddec74edce (patch)
treea3c23ca1ef525340d98e01bb53fc9e6785ce45ff /Python/thread_pthread.h
parent0d48f974662035c14912d225b71b6cf93b621bb0 (diff)
parent0675102eeb39b5bf471af40e8af6729102fccc6b (diff)
downloadcpython-4278e8cf357c7418651ca0e23346b2ddec74edce.tar.gz
Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X.
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 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