From 589cc78cb8698b49aa408c6411c8720a2a0efe3c Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Thu, 14 Sep 2017 12:21:48 -0700 Subject: [PATCH] Use memmove() instead of memcpy() since regions may overlap. --- src/rtpp_command_async.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rtpp_command_async.c b/src/rtpp_command_async.c index 723c74ba6..6f1a97243 100644 --- a/src/rtpp_command_async.c +++ b/src/rtpp_command_async.c @@ -435,10 +435,11 @@ rtpp_cmd_queue_run(void *arg) rtpp_cmd_connection_dtor(psp->rccs[i]); psp->pfds_used--; if (psp->pfds_used > 0 && i < psp->pfds_used) { - memcpy(&psp->pfds[i], &psp->pfds[i + 1], + memmove(&psp->pfds[i], &psp->pfds[i + 1], (psp->pfds_used - i) * sizeof(struct pollfd)); - memcpy(&psp->rccs[i], &psp->rccs[i + 1], + memmove(&psp->rccs[i], &psp->rccs[i + 1], (psp->pfds_used - i) * sizeof(struct rtpp_ctrl_connection *)); + i--; } } }