From 2cca2c0b4e8ffcd6b04396f59290dd8f9a6a690e Mon Sep 17 00:00:00 2001 From: James Turner <james@flightgear.org> Date: Thu, 2 Sep 2021 11:10:47 +0100 Subject: [PATCH] Fix an ASan error This code can overlap its source and destination ranges, so replace memcpy with memmove. --- 3rdparty/iaxclient/lib/spandsp/plc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/3rdparty/iaxclient/lib/spandsp/plc.c b/3rdparty/iaxclient/lib/spandsp/plc.c index 4edbb2dc5..4efd4183e 100644 --- a/3rdparty/iaxclient/lib/spandsp/plc.c +++ b/3rdparty/iaxclient/lib/spandsp/plc.c @@ -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; }