Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug #570
Browse files Browse the repository at this point in the history
SDL_SemWaitTimeout in src/thread/generic/SDL_syssem.c line 179 (SVN trunk):

--sem->count;

should be

if (retval == 0) {
    --sem->count;
}

Without this, sem->count will underflow on timeout effectively breaking the
semaphore. It appears that the implementation has been wrong since the initial
revision.
  • Loading branch information
slouken committed Sep 21, 2009
1 parent 24ba42b commit e95881b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/thread/generic/SDL_syssem.c
Expand Up @@ -176,7 +176,9 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
sem->count_lock, timeout);
}
--sem->waiters_count;
--sem->count;
if (retval == 0) {
--sem->count;
}
SDL_UnlockMutex(sem->count_lock);

return retval;
Expand Down

0 comments on commit e95881b

Please sign in to comment.