Skip to content

Commit 08885fc

Browse files
committed
Fix buffer underflow
Fixes #428
1 parent 5fd04d4 commit 08885fc

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/SSD1306I2C.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ class SSD1306I2C : public OLEDDisplay {
130130
}
131131

132132
private:
133+
// Reserve 1 byte before the framebuffer so display() can safely write the
134+
// I2C control byte (0x40) to buffer[-1] without accessing unallocated memory.
133135
int getBufferOffset(void) {
134-
return 0;
136+
return 1;
135137
}
136138

137139
inline void sendCommand(uint8_t command) __attribute__((always_inline)) {

0 commit comments

Comments
 (0)