mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-24 22:47:06 -04:00
fix: move sendFrame inside mutex scope to prevent race condition
sendFrame() reads frames[curr_frame_id-1] but was called outside the mutex scope. The command processor thread (running processCommand via checkCommandQueue) can modify curr_frame_id or reload the event (clearing/rebuilding frames) between the mutex unlock and the sendFrame call, causing out-of-bounds access. Move sendFrame into the first mutex scope so frames[] access is protected from concurrent modification by the command thread. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1079,22 +1079,18 @@ void EventStream::runStream() {
|
||||
|
||||
continue;
|
||||
} // end if !in_event
|
||||
} // end scope for mutex lock
|
||||
|
||||
if (send_frame) {
|
||||
if (!sendFrame(delta)) {
|
||||
zm_terminate = true;
|
||||
break;
|
||||
if (send_frame) {
|
||||
if (!sendFrame(delta)) {
|
||||
zm_terminate = true;
|
||||
break;
|
||||
}
|
||||
if (send_twice and !sendFrame(delta)) {
|
||||
zm_terminate = true;
|
||||
break;
|
||||
}
|
||||
frame_count++;
|
||||
}
|
||||
if (send_twice and !sendFrame(delta)) {
|
||||
zm_terminate = true;
|
||||
break;
|
||||
}
|
||||
frame_count++;
|
||||
}
|
||||
|
||||
{
|
||||
std::scoped_lock lck{mutex};
|
||||
|
||||
if (!paused && !event_data->frames.empty()
|
||||
&& curr_frame_id >= 1 && curr_frame_id <= (int)event_data->frames.size()) {
|
||||
|
||||
Reference in New Issue
Block a user