diff --git a/tests/unit/test_ctl.c b/tests/unit/test_ctl.c index cdc57aa4bb..5949882360 100644 --- a/tests/unit/test_ctl.c +++ b/tests/unit/test_ctl.c @@ -181,11 +181,14 @@ static void test_uc_ctl_change_page_size(void) { uc_engine *uc; uc_engine *uc2; + uint32_t pg = 0; OK(uc_open(UC_ARCH_ARM, UC_MODE_ARM, &uc)); OK(uc_open(UC_ARCH_ARM, UC_MODE_ARM, &uc2)); OK(uc_ctl_set_page_size(uc, 4096)); + OK(uc_ctl_get_page_size(uc, &pg)); + TEST_CHECK(pg == 4096); OK(uc_mem_map(uc2, 1 << 10, 1 << 10, UC_PROT_ALL)); uc_assert_err(UC_ERR_ARG, uc_mem_map(uc, 1 << 10, 1 << 10, UC_PROT_ALL)); diff --git a/uc.c b/uc.c index bc8019ea4b..dfddbec7e8 100644 --- a/uc.c +++ b/uc.c @@ -2523,7 +2523,8 @@ uc_err uc_ctl(uc_engine *uc, uc_control_type control, ...) break; } - while (page_size) { + // Bits is used to calculate the mask + while (page_size > 1) { bits++; page_size >>= 1; }