Commit e6a160093a64733c581e80feebd1e9acb0ac765e

Authored by Wiebe Cazemier
1 parent e6224fd3

Protect against circular buffer overflow

Showing 1 changed file with 5 additions and 0 deletions
cirbuf.cpp
@@ -110,6 +110,11 @@ void CirBuf::ensureFreeSpace(size_t n, const size_t max) @@ -110,6 +110,11 @@ void CirBuf::ensureFreeSpace(size_t n, const size_t max)
110 if (n <= freeSpace()) 110 if (n <= freeSpace())
111 return; 111 return;
112 112
  113 + if (size >= 2147483648)
  114 + {
  115 + throw std::runtime_error("Trying to exceed circular buffer beyond its 2 GB limit.");
  116 + }
  117 +
113 const size_t _usedBytes = usedBytes(); 118 const size_t _usedBytes = usedBytes();
114 119
115 int mul = 1; 120 int mul = 1;