Skip to content

Commit 92a465a

Browse files
JakubVanekdlech
andauthored
fix(flash): Check for calloc failure
Co-authored-by: David Lechner <david@lechnology.com>
1 parent 271134c commit 92a465a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/bl_install.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ static int bootloader_send(FILE *fp, int length, u32* pCrc32)
261261
int bootloader_crc(FILE *fp, u32 starting_sector, u32 num_sectors, bool verbose)
262262
{
263263
u8 *firmware = calloc(FLASH_SIZE, 1);
264+
if (!firmware) {
265+
errmsg = "out of memory";
266+
return ERR_NOMEM;
267+
}
264268
u32 read_bytes = fread(firmware, 1, FLASH_SIZE, fp);
265269
if (ferror(fp)) {
266270
errmsg = "Reading of firmware file failed";

0 commit comments

Comments
 (0)