[Horus] Malloc check added
This commit is contained in:
@@ -617,7 +617,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitmapBuffer * bmp = new BitmapBuffer(BMP_RGB565, w, h);
|
BitmapBuffer * bmp = new BitmapBuffer(BMP_RGB565, w, h);
|
||||||
if (bmp == NULL) {
|
if (bmp == NULL || bmp->getData() == NULL) {
|
||||||
f_close(&imgFile);
|
f_close(&imgFile);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
|||||||
|
|
||||||
inline void drawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags)
|
inline void drawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags)
|
||||||
{
|
{
|
||||||
if (h==0 || w==0) return;
|
if (!data || h==0 || w==0) return;
|
||||||
if (h<0) { y+=h; h=-h; }
|
if (h<0) { y+=h; h=-h; }
|
||||||
if (w<0) { x+=w; w=-w; }
|
if (w<0) { x+=w; w=-w; }
|
||||||
DMAFillRect(data, width, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
DMAFillRect(data, width, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
||||||
@@ -219,7 +219,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
|||||||
template<class 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)
|
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 || x >= width || y >= height)
|
if (!data || !bmp || x >= width || y >= height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
coord_t srcw = bmp->getWidth();
|
coord_t srcw = bmp->getWidth();
|
||||||
|
|||||||
Reference in New Issue
Block a user