summaryrefslogtreecommitdiff
path: root/ptw32_semwait.c
diff options
context:
space:
mode:
authorrpj <rpj>2007-01-06 13:44:39 +0000
committerrpj <rpj>2007-01-06 13:44:39 +0000
commit35dec51214f692110f441cd68a94cbd264574d18 (patch)
tree1ce9711f604c6799eea806f40b22ce02574b8ae6 /ptw32_semwait.c
parenteeef426b8399ad39dfc759352a6e7b0348a047d1 (diff)
See ChangeLog
Diffstat (limited to 'ptw32_semwait.c')
-rw-r--r--ptw32_semwait.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/ptw32_semwait.c b/ptw32_semwait.c
index 8b23d11..111cb80 100644
--- a/ptw32_semwait.c
+++ b/ptw32_semwait.c
@@ -77,8 +77,18 @@ ptw32_semwait (sem_t * sem)
{
if ((result = pthread_mutex_lock (&s->lock)) == 0)
{
- int v = --s->value;
+ int v;
+ /* See sem_destroy.c
+ */
+ if (*sem == NULL)
+ {
+ (void) pthread_mutex_unlock (&s->lock);
+ errno = EINVAL;
+ return -1;
+ }
+
+ v = --s->value;
(void) pthread_mutex_unlock (&s->lock);
if (v < 0)
@@ -89,6 +99,13 @@ ptw32_semwait (sem_t * sem)
#ifdef NEED_SEM
if (pthread_mutex_lock (&s->lock) == 0)
{
+ if (*sem == NULL)
+ {
+ (void) pthread_mutex_unlock (&s->lock);
+ errno = EINVAL;
+ return -1;
+ }
+
if (s->leftToUnblock > 0)
{
--s->leftToUnblock;