cwe.mitre.org/data/definitions/362.html
Example 2
The following function attempts to acquire a lock in order toperform operations on a shared resource.
(Bad Code)
ExampleLanguage: C
void f(pthread_mutex_t *mutex) {
pthread_mutex_lock(mutex);
/* access shared resource */
pthread_mutex_unlock(mutex);
}
However, the code does not check the value returned bypthread_mutex_lock() for errors. If pthread_mutex_lock() cannot acquirethe mutex for any reason, the function may introduce a race conditioninto the program and result in undefined behavior.
In order to avoid data races, correctly written programs must checkthe result of thread synchronization functions and appropriately handleall errors, either by attempting to recover from them or reporting it tohigher levels.