X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ccdbg-hex.c;h=86478da07b8c5f262c6adfb675cccf6aa11f2528;hp=ff155ff3f8fcbc0d6967b03d0408d95ad800593e;hb=b4d1127ef007843c643b778b3b2f6b915b1d5d9a;hpb=55995515b9d4fc1e193039eab697c5d03db417c2 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;