diff --git a/mrfCommon/src/flash.cpp b/mrfCommon/src/flash.cpp index 04ed73b7c..77d9768e9 100644 --- a/mrfCommon/src/flash.cpp +++ b/mrfCommon/src/flash.cpp @@ -371,14 +371,16 @@ void CFIFlash::busyWait(double timeout, unsigned n) CFIStreamBuf::CFIStreamBuf(CFIFlash& flash) :flash(flash) ,pos(0u) -{} +{ + buf.resize(1); +} CFIStreamBuf::int_type CFIStreamBuf::underflow() { // read-ahead is only one page buf.resize(flash.pageSize()); flash.read(pos, buf.size(), (epicsUInt8*)&buf[0]); - setg(&buf[0], &buf[0], &buf[buf.size()]); + setg(&buf[0], &buf[0], &buf[buf.size()-1]); pos += buf.size(); return buf[0];