@@ -222,6 +222,11 @@ bool Image::drawBitmapFromWeb(const char *url, int x, int y, bool dither, bool i
222222 buf = downloadFileHTTPS (url, &defaultLen);
223223 }
224224
225+ // Image sometimes doesn't download, so
226+ // check if buffer is empty to avoid trying to draw an empty image
227+ if (!buf)
228+ return 0 ;
229+
225230 ret = drawBitmapFromBuffer (buf, x, y, dither, invert);
226231 free (buf);
227232
@@ -251,6 +256,11 @@ bool Image::drawBitmapFromWeb(WiFiClient *s, int x, int y, int32_t len, bool dit
251256 bool ret = 0 ;
252257 uint8_t *buf = downloadFile (s, len);
253258
259+ // Image sometimes doesn't download, so
260+ // check if buffer is empty to avoid trying to draw an empty image
261+ if (!buf)
262+ return 0 ;
263+
254264 ret = drawBitmapFromBuffer (buf, x, y, dither, invert);
255265 free (buf);
256266
@@ -520,6 +530,11 @@ bool Image::drawBmpFromWebAtPosition(const char *url, const Position &position,
520530 int32_t defaultLen = E_INK_WIDTH * E_INK_HEIGHT * 4 + 150 ;
521531 uint8_t *buf = downloadFileHTTPS (url, &defaultLen);
522532
533+ // Image sometimes doesn't download, so
534+ // check if buffer is empty to avoid trying to draw an empty image
535+ if (!buf)
536+ return 0 ;
537+
523538 bitmapHeader bmpHeader;
524539 readBmpHeader (buf, &bmpHeader);
525540
0 commit comments