[Horus] Protection against buffer overflow

This commit is contained in:
Bertrand Songis
2016-11-21 18:40:22 +01:00
parent 34fa612f07
commit 4b84cd27b2
2 changed files with 4 additions and 2 deletions
+3 -2
View File
@@ -198,7 +198,8 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
template<class T>
void drawBitmap(coord_t x, coord_t y, const T * bmp, coord_t srcx=0, coord_t srcy=0, coord_t w=0, coord_t h=0, float scale=0)
{
if (!bmp) return;
if (!bmp || x >= width || y >= height)
return;
int srcw = bmp->getWidth();
int srch = bmp->getHeight();
@@ -211,7 +212,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
w = srcw - srcx;
if (srcy+h > srch)
h = srch - srcy;
if (scale == 0) {
if (x + w > width) {
w = width - x;
+1
View File
@@ -77,6 +77,7 @@ enum FontSizeIndex {
SPAREf_INDEX,
};
#define STDSIZE (STDSIZE_INDEX << 8)
#define TINSIZE (TINSIZE_INDEX << 8)
#define SMLSIZE (SMLSIZE_INDEX << 8)
#define MIDSIZE (MIDSIZE_INDEX << 8)