Fixed broken Dequeue() stopping condition

The CRingBuffer::Dequeue() function did not respect the nMaxCount
parameter, leading to buffer overflow/memory corruption.
This commit is contained in:
Dale Whinham committed 2023-02-24 19:16:28 +00:00
1 parent ef1fb82a00
commit 24e072cbc3
2 files changed
+5 -1

No files matched your search

+4
View File
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Memory corruption/crashing caused by faulty ring buffer dequeue implementation.
## [0.13.0] - 2023-02-23
### Added
+1 -1
View File
@@ -87,7 +87,7 @@ public:
size_t nDequeued = 0;
m_Lock.Acquire();
while (m_nInPtr != m_nOutPtr)
while (m_nInPtr != m_nOutPtr && nDequeued < nMaxCount)
{
pOutBuffer[nDequeued++] = m_Data[m_nOutPtr++];
m_nOutPtr &= BufferMask;