1
0
Fork 0

Fix an ASan error

This code can overlap its source and destination ranges, so replace
memcpy with memmove.
This commit is contained in:
James Turner 2021-09-02 11:10:47 +01:00
parent 08aed1ccc8
commit 2cca2c0b4e

View file

@ -107,7 +107,9 @@ static void normalise_history(plc_state_t *s)
if (s->buf_ptr == 0)
return;
memcpy(tmp, s->history, sizeof(int16_t)*s->buf_ptr);
memcpy(s->history, s->history + s->buf_ptr, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr));
// FlightGear fix: use memove, becuase ASan reports overlaps here
memmove(s->history, s->history + s->buf_ptr, sizeof(int16_t)*(PLC_HISTORY_LEN - s->buf_ptr));
memcpy(s->history + PLC_HISTORY_LEN - s->buf_ptr, tmp, sizeof(int16_t)*s->buf_ptr);
s->buf_ptr = 0;
}