提交 81c7cc9e authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

RtpStreamSend.cpp: may fix crash in RtpStreamSend::StorePacket when it receives…

RtpStreamSend.cpp: may fix crash in RtpStreamSend::StorePacket when it receives an oldest packet and there is no space left in the storage
上级 f1b8d026
...@@ -332,7 +332,7 @@ namespace RTC ...@@ -332,7 +332,7 @@ namespace RTC
// If empty do it easy. // If empty do it easy.
if (this->buffer.empty()) if (this->buffer.empty())
{ {
auto store = this->storage[0].store; auto* store = this->storage[0].store;
bufferItem.packet = packet->Clone(store); bufferItem.packet = packet->Clone(store);
this->buffer.push_back(bufferItem); this->buffer.push_back(bufferItem);
...@@ -369,7 +369,13 @@ namespace RTC ...@@ -369,7 +369,13 @@ namespace RTC
// The packet was older than anything in the buffer, store it at the beginning. // The packet was older than anything in the buffer, store it at the beginning.
if (bufferItReverse == this->buffer.rend()) if (bufferItReverse == this->buffer.rend())
{
// Special case: No space in the buffer to store it. Just ignore the packet.
if (this->buffer.size() == this->storage.size())
return;
newBufferIt = this->buffer.insert(this->buffer.begin(), bufferItem); newBufferIt = this->buffer.insert(this->buffer.begin(), bufferItem);
}
// If the buffer is not full use the next free storage item. // If the buffer is not full use the next free storage item.
if (this->buffer.size() - 1 < this->storage.size()) if (this->buffer.size() - 1 < this->storage.size())
...@@ -380,7 +386,7 @@ namespace RTC ...@@ -380,7 +386,7 @@ namespace RTC
else else
{ {
auto& firstBufferItem = *(this->buffer.begin()); auto& firstBufferItem = *(this->buffer.begin());
auto firstPacket = firstBufferItem.packet; auto* firstPacket = firstBufferItem.packet;
// Store points to the store used by the first packet. // Store points to the store used by the first packet.
store = const_cast<uint8_t*>(firstPacket->GetData()); store = const_cast<uint8_t*>(firstPacket->GetData());
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论