Fix potential outofbounds access to image_buffer in getSnapshot()
This commit is contained in:
parent
e246083be5
commit
6f977da94d
|
@ -1162,7 +1162,7 @@ void Monitor::AddPrivacyBitmask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Monitor::GetImage(int32_t index, int scale) {
|
int Monitor::GetImage(int32_t index, int scale) {
|
||||||
if ( index < 0 || index > image_buffer_count ) {
|
if (index < 0 || index > image_buffer_count) {
|
||||||
index = shared_data->last_write_index;
|
index = shared_data->last_write_index;
|
||||||
}
|
}
|
||||||
if ( index != image_buffer_count ) {
|
if ( index != image_buffer_count ) {
|
||||||
|
@ -1193,12 +1193,14 @@ int Monitor::GetImage(int32_t index, int scale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ZMPacket *Monitor::getSnapshot(int index) const {
|
ZMPacket *Monitor::getSnapshot(int index) const {
|
||||||
|
if ((index < 0) || (index >= image_buffer_count)) {
|
||||||
if ( (index < 0) || (index > image_buffer_count) ) {
|
|
||||||
index = shared_data->last_write_index;
|
index = shared_data->last_write_index;
|
||||||
}
|
}
|
||||||
|
if (index != image_buffer_count) {
|
||||||
return new ZMPacket(image_buffer[index], shared_timestamps[index]);
|
return new ZMPacket(image_buffer[index], shared_timestamps[index]);
|
||||||
|
} else {
|
||||||
|
Error("Unable to generate image, no images in buffer");
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue