overrun() needs to return the available space
diff --git a/tests/encperf.cxx b/tests/encperf.cxx
index 6b1119a..0620738 100644
--- a/tests/encperf.cxx
+++ b/tests/encperf.cxx
@@ -158,6 +158,9 @@
 int DummyOutStream::overrun(int itemSize, int nItems)
 {
   flush();
+  if (itemSize * nItems > end - ptr)
+    nItems = (end - ptr) / itemSize;
+  return nItems;
 }
 
 CConn::CConn(const char *filename)