From b4d1127ef007843c643b778b3b2f6b915b1d5d9a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 19 Dec 2008 14:19:29 -0800 Subject: Flash multiple pages. Eliminate off-by-one error in hex_image length. Signed-off-by: Keith Packard --- ccdbg-hex.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ccdbg-hex.c') diff --git a/ccdbg-hex.c b/ccdbg-hex.c index ff155ff3..86478da0 100644 --- a/ccdbg-hex.c +++ b/ccdbg-hex.c @@ -119,6 +119,8 @@ ccdbg_hex_read_record(struct hex_input *input) ccdbg_hex_error(input, "Unexpected EOF"); goto bail; } + if (c == ' ') + continue; if (c == '\n') input->line++; switch (state) { @@ -290,17 +292,19 @@ ccdbg_hex_image_create(struct hex_file *hex) int i; uint32_t base, bound; uint32_t offset; + int length; first = hex->records[0]; last = hex->records[hex->nrecord - 2]; /* skip EOF */ base = (uint32_t) first->address; - bound = (uint32_t) last->address + (uint32_t) last->length - 1; - image = calloc(sizeof(struct hex_image) + bound - base, 1); + bound = (uint32_t) last->address + (uint32_t) last->length; + length = bound - base; + image = calloc(sizeof(struct hex_image) + length, 1); if (!image) return NULL; image->address = base; - image->length = bound - base; - memset(image->data, 0xff, image->length); + image->length = length; + memset(image->data, 0xff, length); for (i = 0; i < hex->nrecord - 1; i++) { record = hex->records[i]; offset = record->address - base; -- cgit v1.2.3