mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
Call ftpl_init before using monotonic_conds_lock
Otherwise we can use this in an uninitialised state, which is not allowed. We call ftpl_init in pthread_cond_init_232, but the application might not have called that. For example, it might have a static condition variable set up with PTHREAD_COND_INITIALIZER.
This commit is contained in:
@@ -3705,6 +3705,8 @@ int pthread_cond_destroy_232(pthread_cond_t *cond)
|
||||
{
|
||||
struct pthread_cond_monotonic* e;
|
||||
|
||||
ftpl_init();
|
||||
|
||||
if (pthread_rwlock_trywrlock(&monotonic_conds_lock) != 0) {
|
||||
sched_yield();
|
||||
return EBUSY;
|
||||
@@ -3787,6 +3789,8 @@ int pthread_cond_timedwait_common(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
clockid_t clk_id;
|
||||
int result = 0;
|
||||
|
||||
ftpl_init();
|
||||
|
||||
if (abstime != NULL)
|
||||
{
|
||||
if (pthread_rwlock_tryrdlock(&monotonic_conds_lock) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user