Skip to content

Commit 43d0467

Browse files
authored
Merge pull request #26 from LeeLeahy2/fix-corruption
Fix heap corruption caused by specifying an x value outside of display
2 parents 9709716 + a6f30cd commit 43d0467

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/qwiic_grssd1306.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
} while (false)
131131

132132
// Macro to check and adjust record bounds based on a single location
133+
// The _x_ value must be within the screen (0 <= x < width), limit
134+
// values are ignored
133135
#define pageCheckBounds(_page_, _x_) \
134136
do \
135137
{ \
@@ -140,6 +142,8 @@
140142
} while (false)
141143

142144
// Macro to check and adjust record bounds using another page descriptor
145+
// The _page2_ x values must be within the screen (0 <= x < width), limit
146+
// values are ignored
143147
#define pageCheckBoundsDesc(_page_, _page2_) \
144148
do \
145149
{ \
@@ -150,6 +154,7 @@
150154
} while (false)
151155

152156
// Macro to check and adjust record bounds using bounds values
157+
// Values _x0_ and _x1_ must be within the screen (0 <= x < width)
153158
#define pageCheckBoundsRange(_page_, _x0_, _x1_) \
154159
do \
155160
{ \
@@ -880,7 +885,7 @@ void QwGrSSD1306::drawBitmap(uint8_t x0, uint8_t y0, uint8_t dst_width, uint8_t
880885
bmp_y += neededBits;
881886

882887
pageCheckBoundsRange(m_pageState[iPage], x0,
883-
x0 + dst_width); // mark dirty range in page desc
888+
x0 + dst_width - 1); // mark dirty range in page desc
884889
}
885890
}
886891

@@ -1014,4 +1019,4 @@ void QwGrSSD1306::sendDevCommand(uint8_t command, uint8_t value)
10141019
void QwGrSSD1306::sendDevData(uint8_t *pData, uint8_t nData)
10151020
{
10161021
m_i2cBus->writeRegisterRegion(m_i2cAddress, kDeviceSendData, pData, nData);
1017-
}
1022+
}

0 commit comments

Comments
 (0)