mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-23 23:32:45 +00:00
We missed the size multiplier for memset()
In doing so, only a small portion of memory would have reliably been set to zero; specifically, just the first element! This change should resolve some intermittent test failures to guarantee that all memory be zeroed.
This commit is contained in:
parent
ed1a7b3278
commit
3f3210205f
@ -40,7 +40,7 @@ vm_segment_create(size_t size)
|
|||||||
|
|
||||||
// We should zero out memory and make explicit that any new segment
|
// We should zero out memory and make explicit that any new segment
|
||||||
// begins life in that state.
|
// begins life in that state.
|
||||||
memset(segment->memory, 0, sizeof(vm_8bit));
|
memset(segment->memory, 0, sizeof(vm_8bit) * size);
|
||||||
|
|
||||||
segment->read_table = malloc(sizeof(vm_segment_read_fn) * size);
|
segment->read_table = malloc(sizeof(vm_segment_read_fn) * size);
|
||||||
if (segment->read_table == NULL) {
|
if (segment->read_table == NULL) {
|
||||||
@ -59,8 +59,8 @@ vm_segment_create(size_t size)
|
|||||||
// read/write mapper code to attempt to a run a function with
|
// read/write mapper code to attempt to a run a function with
|
||||||
// garbage. We could have undefined garbage! We can only properly
|
// garbage. We could have undefined garbage! We can only properly
|
||||||
// work with defined garbage.
|
// work with defined garbage.
|
||||||
memset(segment->read_table, (int)NULL, sizeof(vm_segment_read_fn));
|
memset(segment->read_table, (int)NULL, sizeof(vm_segment_read_fn) * size);
|
||||||
memset(segment->write_table, (int)NULL, sizeof(vm_segment_write_fn));
|
memset(segment->write_table, (int)NULL, sizeof(vm_segment_write_fn) * size);
|
||||||
|
|
||||||
segment->size = size;
|
segment->size = size;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user