mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
ringbuffer: fix invalid read access
Fix read access to a free'ed memory when waiting for audio data. Refs #73286 Change-Id: Iefbe6e4540c14a114cd4c8684ff91445eb290922
This commit is contained in:
@ -266,11 +266,19 @@ size_t RingBuffer::waitForDataAvailable(const std::string &call_id, const size_t
|
||||
size_t getl = 0;
|
||||
if (deadline == std::chrono::high_resolution_clock::time_point()) {
|
||||
not_empty_.wait(l, [=, &getl] {
|
||||
getl = (endPos_ + buffer_size - read_ptr->second) % buffer_size;
|
||||
// Re-find read_ptr: it may be destroyed during the wait
|
||||
const auto read_ptr = readoffsets_.find(call_id);
|
||||
if (read_ptr == readoffsets_.end())
|
||||
return true;
|
||||
getl = (endPos_ + buffer_size - read_ptr->second) % buffer_size;
|
||||
return getl >= min_data_length;
|
||||
});
|
||||
} else {
|
||||
not_empty_.wait_until(l, deadline, [=, &getl]{
|
||||
// Re-find read_ptr: it may be destroyed during the wait
|
||||
const auto read_ptr = readoffsets_.find(call_id);
|
||||
if (read_ptr == readoffsets_.end())
|
||||
return true;
|
||||
getl = (endPos_ + buffer_size - read_ptr->second) % buffer_size;
|
||||
return getl >= min_data_length;
|
||||
});
|
||||
|
Reference in New Issue
Block a user