Skip to content

Commit 7d8b06b

Browse files
snapshot restore don't remove terminating regions (#1968)
1 parent ddd6b7c commit 7d8b06b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/unit/test_mem.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ static void test_snapshot(void)
280280
uc_engine *uc;
281281
uc_context *c0, *c1;
282282
uint32_t mem;
283+
uint8_t code_data;
283284
// mov eax, [0x2020]; inc eax; mov [0x2020], eax
284285
char code[] = "\xa1\x20\x20\x00\x00\x00\x00\x00\x00\xff\xc0\xa3\x20\x20\x00"
285286
"\x00\x00\x00\x00\x00";
@@ -302,13 +303,15 @@ static void test_snapshot(void)
302303
OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem)));
303304
TEST_CHECK(mem == 2);
304305
OK(uc_context_restore(uc, c1));
305-
// TODO check mem
306+
306307
OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem)));
307308
TEST_CHECK(mem == 1);
308309
OK(uc_context_restore(uc, c0));
309310
OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem)));
310311
TEST_CHECK(mem == 0);
311-
// TODO check mem
312+
313+
OK(uc_mem_read(uc, 0x1000, &code_data, sizeof(code_data)));
314+
TEST_CHECK(code_data == 0xa1);
312315

313316
OK(uc_context_free(c0));
314317
OK(uc_context_free(c1));

uc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,7 @@ static uc_err uc_restore_latest_snapshot(struct uc_struct *uc)
28372837
subregions_link, subregion_next)
28382838
{
28392839
uc->memory_filter_subregions(subregion, uc->snapshot_level);
2840-
if (QTAILQ_EMPTY(&subregion->subregions)) {
2840+
if (subregion->priority >= uc->snapshot_level || (!subregion->terminates && QTAILQ_EMPTY(&subregion->subregions))) {
28412841
uc->memory_unmap(uc, subregion);
28422842
}
28432843
}

0 commit comments

Comments
 (0)