diff --git a/dsim.c b/dsim.c index 86f23bb..f58bf72 100644 --- a/dsim.c +++ b/dsim.c @@ -525,12 +525,14 @@ int load_image(char *filename) int fd; ssize_t r; ssize_t pos; + uint8_t *buf; fd = open(filename, O_RDONLY); if (fd < 0) return fd; + buf = (uint8_t *)ram; for (pos=0;;) { - r = read(fd, &ram[pos], sizeof(ram)); + r = read(fd, &buf[pos], sizeof(ram)-pos); if (r > 0) pos += r; else {