target.c: Check for valid flash structure.

This commit is contained in:
Uwe Bonnes 2020-04-25 13:44:41 +02:00
parent 60f39f55b4
commit 966ac4036d

View File

@ -256,6 +256,8 @@ int target_flash_write(target *t,
int ret = 0; int ret = 0;
while (len) { while (len) {
struct target_flash *f = flash_for_addr(t, dest); struct target_flash *f = flash_for_addr(t, dest);
if (!f)
return 1;
size_t tmptarget = MIN(dest + len, f->start + f->length); size_t tmptarget = MIN(dest + len, f->start + f->length);
size_t tmplen = tmptarget - dest; size_t tmplen = tmptarget - dest;
ret |= target_flash_write_buffered(f, dest, src, tmplen); ret |= target_flash_write_buffered(f, dest, src, tmplen);