summaryrefslogtreecommitdiff
path: root/libcpu/mips
diff options
context:
space:
mode:
authord1zzy126 <[email protected]>2023-04-14 14:06:43 +0800
committerGitHub <[email protected]>2023-04-14 14:06:43 +0800
commit5c1b071a0ce8ad5a120ec32e37ffc9c17fb09b29 (patch)
tree7e20bc2a5bbc7c8bbf67d057af5ac2ef473c13a5 /libcpu/mips
parentef1b3383a602f584dba8830f1568153c3b01922c (diff)
[HUST][CSE]mips/common/exception.c/rt_set_except_vector (#7238)
* mips/common/exception.c/rt_set_except_vector * Update exception.c --------- Co-authored-by: Bernard Xiong <[email protected]>
Diffstat (limited to 'libcpu/mips')
-rw-r--r--libcpu/mips/common/exception.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libcpu/mips/common/exception.c b/libcpu/mips/common/exception.c
index ca048a926b..5c458c9eb1 100644
--- a/libcpu/mips/common/exception.c
+++ b/libcpu/mips/common/exception.c
@@ -82,13 +82,14 @@ exception_func_t sys_exception_handlers[RT_EXCEPTION_MAX];
*/
exception_func_t rt_set_except_vector(int n, exception_func_t func)
{
- exception_func_t old_handler = sys_exception_handlers[n];
+ exception_func_t old_handler;
- if ((n == 0) || (n > RT_EXCEPTION_MAX) || (!func))
+ if ((n < 0) || (n >= RT_EXCEPTION_MAX) || (!func))
{
return 0;
}
+ old_handler = sys_exception_handlers[n];
sys_exception_handlers[n] = func;
return old_handler;