You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If given a shift value larger than or equal to the length of the buffer region being shifted, ManagedBuffer will simply fill the entire buffer with zero, rather than the intended buffer region:
#include<MicroBit.h>
MicroBit uBit;
intmain() {
uBit.init();
ManagedBuffer buf(32);
//Fill some unrelated very important bytes with data.
buf.fill(0xAA, 0, sizeof(int));
//Fill some other region, and then attempt a large shift.
buf.fill(0xBB, 16, 16);
buf.shift(1000, 16, 16);
//Our very important data has now been overwritten with zero...int* important_data = reinterpret_cast<int*>(buf.getBytes());
while (true)
uBit.display.scroll(*important_data);
}
This seems like a simple fix, and seems to work fine when L306-309 are changed to instead read:
If given a shift value larger than or equal to the length of the buffer region being shifted,
ManagedBuffer
will simply fill the entire buffer with zero, rather than the intended buffer region:codal-core/source/types/ManagedBuffer.cpp
Lines 306 to 309 in f08eb30
This can be reproduced with the following MRE:
This seems like a simple fix, and seems to work fine when L306-309 are changed to instead read:
The text was updated successfully, but these errors were encountered: