summaryrefslogtreecommitdiff
path: root/sysdeps/hurd/pt-setspecific.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/hurd/pt-setspecific.c')
-rw-r--r--sysdeps/hurd/pt-setspecific.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdeps/hurd/pt-setspecific.c b/sysdeps/hurd/pt-setspecific.c
index 89ca4d7..d0b7302 100644
--- a/sysdeps/hurd/pt-setspecific.c
+++ b/sysdeps/hurd/pt-setspecific.c
@@ -28,6 +28,10 @@ pthread_setspecific (pthread_key_t key, const void *value)
error_t err;
struct __pthread *self = _pthread_self ();
+ if (key < 0 || key >= __pthread_key_count
+ || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
+ return EINVAL;
+
if (! self->thread_specifics)
{
err = hurd_ihash_create (&self->thread_specifics, HURD_IHASH_NO_LOCP);