mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-23 12:03:41 +01:00
coredump: simplify bad regnum checks a little
We always want to reject negative regnums since we use it as an index, so make it a common check at the top for all arches.
This commit is contained in:
parent
00cca00716
commit
f3f456c0d1
1 changed files with 8 additions and 5 deletions
|
@ -39,17 +39,20 @@ _UCD_access_reg (unw_addr_space_t as,
|
|||
return -UNW_EINVAL;
|
||||
}
|
||||
|
||||
if (regnum < 0)
|
||||
goto badreg;
|
||||
|
||||
#if defined(UNW_TARGET_AARCH64)
|
||||
if (regnum < 0 || regnum >= UNW_AARCH64_FPCR)
|
||||
if (regnum >= UNW_AARCH64_FPCR)
|
||||
goto badreg;
|
||||
#elif defined(UNW_TARGET_ARM)
|
||||
if (regnum < 0 || regnum >= 16)
|
||||
if (regnum >= 16)
|
||||
goto badreg;
|
||||
#elif defined(UNW_TARGET_SH)
|
||||
if (regnum < 0 || regnum > UNW_SH_PR)
|
||||
if (regnum > UNW_SH_PR)
|
||||
goto badreg;
|
||||
#elif defined(UNW_TARGET_TILEGX)
|
||||
if (regnum < 0 || regnum > UNW_TILEGX_CFA)
|
||||
if (regnum > UNW_TILEGX_CFA)
|
||||
goto badreg;
|
||||
#else
|
||||
#if defined(UNW_TARGET_MIPS)
|
||||
|
@ -120,7 +123,7 @@ _UCD_access_reg (unw_addr_space_t as,
|
|||
#error Port me
|
||||
#endif
|
||||
|
||||
if (regnum < 0 || regnum >= (unw_regnum_t)ARRAY_SIZE(remap_regs))
|
||||
if (regnum >= (unw_regnum_t)ARRAY_SIZE(remap_regs))
|
||||
goto badreg;
|
||||
|
||||
regnum = remap_regs[regnum];
|
||||
|
|
Loading…
Reference in a new issue