diff --git a/include/vm_segment.h b/include/vm_segment.h index deb00bb..2ae1eda 100644 --- a/include/vm_segment.h +++ b/include/vm_segment.h @@ -54,7 +54,7 @@ struct vm_segment { }; extern int vm_segment_copy(vm_segment *, vm_segment *, size_t, size_t, size_t); -extern int vm_segment_fread(vm_segment *, FILE *, size_t); +extern int vm_segment_fread(vm_segment *, FILE *, size_t, size_t); extern int vm_segment_read_map(vm_segment *, size_t, vm_segment_read_fn); extern int vm_segment_set(vm_segment *, size_t, vm_8bit); extern int vm_segment_write_map(vm_segment *, size_t, vm_segment_write_fn); diff --git a/src/vm_segment.c b/src/vm_segment.c index 2c5c7f9..ffa4e0d 100644 --- a/src/vm_segment.c +++ b/src/vm_segment.c @@ -226,9 +226,9 @@ vm_segment_write_map(vm_segment *segment, * for some reason, signal that and return an error. */ int -vm_segment_fread(vm_segment *segment, FILE *stream, size_t len) +vm_segment_fread(vm_segment *segment, FILE *stream, size_t offset, size_t len) { - fread(segment->memory, sizeof(vm_8bit), len, stream); + fread(segment->memory + offset, sizeof(vm_8bit), len, stream); // fread() may return zero in the case of an error, but it may // return a positive non-zero number short of len; we can't quite