Avoid null ptr deref when writing to arm context pc register

This commit is contained in:
mio
2025-02-10 15:58:28 +08:00
parent 48fb28dfbc
commit a903fa182b
2 changed files with 9 additions and 2 deletions

View File

@@ -757,12 +757,15 @@ static void test_arm_context_save(void)
uc_engine *uc2;
char code[] = "\x83\xb0"; // sub sp, #0xc
uc_context *ctx;
uint32_t pc;
uc_common_setup(&uc, UC_ARCH_ARM, UC_MODE_THUMB, code, sizeof(code) - 1,
UC_CPU_ARM_CORTEX_R5);
OK(uc_context_alloc(uc, &ctx));
OK(uc_context_save(uc, ctx));
OK(uc_context_reg_read(ctx, UC_ARM_REG_PC, (void*)&pc));
OK(uc_context_reg_write(ctx, UC_ARM_REG_PC, (void*)&pc));
OK(uc_context_restore(uc, ctx));
uc_common_setup(&uc2, UC_ARCH_ARM, UC_MODE_THUMB, code, sizeof(code) - 1,