Fix Overlap Handling in sim_copyfullstate to Prevent Undefined Behavior
This commit is contained in:
parent
4d63921f0a
commit
3e6649856b
1 changed files with 2 additions and 6 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
#include <arch/irq.h>
|
#include <arch/irq.h>
|
||||||
|
|
||||||
#include "sim_internal.h"
|
#include "sim_internal.h"
|
||||||
|
@ -45,8 +46,6 @@
|
||||||
|
|
||||||
void sim_copyfullstate(xcpt_reg_t *dest, xcpt_reg_t *src)
|
void sim_copyfullstate(xcpt_reg_t *dest, xcpt_reg_t *src)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
/* In the sim model, the state is copied from the stack to the TCB,
|
/* In the sim model, the state is copied from the stack to the TCB,
|
||||||
* but only a reference is passed to get the state from the TCB. So the
|
* but only a reference is passed to get the state from the TCB. So the
|
||||||
* following check avoids copying the TCB save area onto itself:
|
* following check avoids copying the TCB save area onto itself:
|
||||||
|
@ -54,9 +53,6 @@ void sim_copyfullstate(xcpt_reg_t *dest, xcpt_reg_t *src)
|
||||||
|
|
||||||
if (src != dest)
|
if (src != dest)
|
||||||
{
|
{
|
||||||
for (i = 0; i < XCPTCONTEXT_REGS; i++)
|
memmove(dest, src, XCPTCONTEXT_REGS * sizeof(xcpt_reg_t));
|
||||||
{
|
|
||||||
*dest++ = *src++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue