diff --git a/tests/unit/test_mem.c b/tests/unit/test_mem.c index 63493c9ad8..eac4774085 100644 --- a/tests/unit/test_mem.c +++ b/tests/unit/test_mem.c @@ -280,6 +280,7 @@ static void test_snapshot(void) uc_engine *uc; uc_context *c0, *c1; uint32_t mem; + uint8_t code_data; // mov eax, [0x2020]; inc eax; mov [0x2020], eax char code[] = "\xa1\x20\x20\x00\x00\x00\x00\x00\x00\xff\xc0\xa3\x20\x20\x00" "\x00\x00\x00\x00\x00"; @@ -302,13 +303,15 @@ static void test_snapshot(void) OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem))); TEST_CHECK(mem == 2); OK(uc_context_restore(uc, c1)); - // TODO check mem + OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem))); TEST_CHECK(mem == 1); OK(uc_context_restore(uc, c0)); OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem))); TEST_CHECK(mem == 0); - // TODO check mem + + OK(uc_mem_read(uc, 0x1000, &code_data, sizeof(code_data))); + TEST_CHECK(code_data == 0xa1); OK(uc_context_free(c0)); OK(uc_context_free(c1)); diff --git a/uc.c b/uc.c index f4d427716b..24c6ade233 100644 --- a/uc.c +++ b/uc.c @@ -2837,7 +2837,7 @@ static uc_err uc_restore_latest_snapshot(struct uc_struct *uc) subregions_link, subregion_next) { uc->memory_filter_subregions(subregion, uc->snapshot_level); - if (QTAILQ_EMPTY(&subregion->subregions)) { + if (subregion->priority >= uc->snapshot_level || (!subregion->terminates && QTAILQ_EMPTY(&subregion->subregions))) { uc->memory_unmap(uc, subregion); } }