fix ringbuffer is nullptr

Change-Id: I6164889ae67fa2c9938c8fcf6f3680b4189e15e6
Signed-off-by: leiguangyu <leiguangyu@huawei.com>
This commit is contained in:
leiguangyu 2024-03-08 11:11:30 +08:00
parent f169cfbedd
commit ffd2a4b80e

View File

@ -37,6 +37,9 @@ size_t RingBuffer::GetFreeSize() const
uint8_t *RingBuffer::AllocForWrite(size_t writeSize)
{
if (buf_ == nullptr || buf_.get() == nullptr) {
return nullptr;
}
size_t writeHead = head_.load(std::memory_order_relaxed);
size_t readHead = tail_.load(std::memory_order_acquire);
size_t writePos = writeHead % size_;