Skip to content

Commit

Permalink
[HUST][CSE]mips/common/exception.c/rt_set_except_vector (RT-Thread#7238)
Browse files Browse the repository at this point in the history
* mips/common/exception.c/rt_set_except_vector

* Update exception.c

---------

Co-authored-by: Bernard Xiong <[email protected]>
  • Loading branch information
d1zzy126 and BernardXiong authored Apr 14, 2023
1 parent ef1b338 commit 5c1b071
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libcpu/mips/common/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5c1b071

Please sign in to comment.