Index: ossp-pkg/pth/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/pth/ChangeLog,v rcsdiff -q -kk '-r1.626' '-r1.627' -u '/v/ossp/cvs/ossp-pkg/pth/ChangeLog,v' 2>/dev/null --- ChangeLog 2004/10/08 16:17:02 1.626 +++ ChangeLog 2004/10/14 14:42:34 1.627 @@ -21,6 +21,9 @@ Changes between 2.0.2 and 2.0.3 (12-Sep-2004 to xx-xxx-2004) + *) Better error checking in pth_key_xxx() functions. + [Ralf S. Engelschall] + *) Added PTH_CTRL_FAVOURNEW control which allows the user to disable the favouring of new threads on scheduling to get more strict priority based scheduling behavior. Index: ossp-pkg/pth/pth_data.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_data.c,v rcsdiff -q -kk '-r1.31' '-r1.32' -u '/v/ossp/cvs/ossp-pkg/pth/pth_data.c,v' 2>/dev/null --- pth_data.c 2004/07/13 10:50:49 1.31 +++ pth_data.c 2004/10/14 14:42:34 1.32 @@ -36,6 +36,8 @@ int pth_key_create(pth_key_t *key, void (*func)(void *)) { + if (key == NULL) + return pth_error(FALSE, EINVAL); for ((*key) = 0; (*key) < PTH_KEY_MAX; (*key)++) { if (pth_keytab[(*key)].used == FALSE) { pth_keytab[(*key)].used = TRUE; @@ -48,20 +50,20 @@ int pth_key_delete(pth_key_t key) { - if (key >= PTH_KEY_MAX) + if (key < 0 || key >= PTH_KEY_MAX) return pth_error(FALSE, EINVAL); if (!pth_keytab[key].used) - return pth_error(FALSE, EINVAL); + return pth_error(FALSE, ENOENT); pth_keytab[key].used = FALSE; return TRUE; } int pth_key_setdata(pth_key_t key, const void *value) { - if (key >= PTH_KEY_MAX) + if (key < 0 || key >= PTH_KEY_MAX) return pth_error(FALSE, EINVAL); if (!pth_keytab[key].used) - return pth_error(FALSE, EINVAL); + return pth_error(FALSE, ENOENT); if (pth_current->data_value == NULL) { pth_current->data_value = (const void **)calloc(1, sizeof(void *)*PTH_KEY_MAX); if (pth_current->data_value == NULL) @@ -81,10 +83,10 @@ void *pth_key_getdata(pth_key_t key) { - if (key >= PTH_KEY_MAX) + if (key < 0 || key >= PTH_KEY_MAX) return pth_error((void *)NULL, EINVAL); if (!pth_keytab[key].used) - return pth_error((void *)NULL, EINVAL); + return pth_error((void *)NULL, ENOENT); if (pth_current->data_value == NULL) return (void *)NULL; return (void *)pth_current->data_value[key];