Skip to content

Commit

Permalink
fix: Correct access out of bonds for buffer used for flash functions
Browse files Browse the repository at this point in the history
This commit fixes issue with flash functions when using gcc >= 11
  • Loading branch information
gabrielfedel committed Jul 30, 2024
1 parent 5b0c1a1 commit 3c4b5fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mrfCommon/src/flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 3c4b5fb

Please sign in to comment.