Skip to content

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 3703677 commit 67255d8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/thread/generic/SDL_syssem.c
Expand Up @@ -165,7 +165,9 @@ int 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 67255d8

Please sign in to comment.