From 25610e5ec5a9fb6b44af5363544ff0b142887c50 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Wed, 4 Oct 2017 14:28:58 +0200 Subject: [PATCH] target: Fix unconsistant use of tmplen. --- src/target/target.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index 54ab8bfc..c984ffe6 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -216,13 +216,14 @@ int target_flash_write(target *t, size_t tmplen = MIN(len, f->length - (dest % f->length)); if (f->align > 1) { uint32_t offset = dest % f->align; - uint8_t data[ALIGN(offset + len, f->align)]; + uint8_t data[ALIGN(offset + tmplen, f->align)]; memset(data, f->erased, sizeof(data)); - memcpy((uint8_t *)data + offset, src, len); + memcpy((uint8_t *)data + offset, src, tmplen); ret |= f->write(f, dest - offset, data, sizeof(data)); } else { ret |= f->write(f, dest, src, tmplen); } + dest += tmplen; src += tmplen; len -= tmplen; }