mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 04:13:34 +08:00
test_mixer & mixer: use memmove instead of memcpy
Both, src & dst use the same array, thus potentially overlapping. Behavior of memcpy in that case is undefined.
This commit is contained in:
@@ -532,7 +532,7 @@ mixer_handle_text(const void *buffer, size_t length)
|
|||||||
|
|
||||||
/* copy any leftover text to the base of the buffer for re-use */
|
/* copy any leftover text to the base of the buffer for re-use */
|
||||||
if (resid > 0) {
|
if (resid > 0) {
|
||||||
memcpy(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid);
|
memmove(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid);
|
||||||
/* enforce null termination */
|
/* enforce null termination */
|
||||||
mixer_text[resid] = '\0';
|
mixer_text[resid] = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ bool MixerTest::load_mixer(const char *filename, const char *buf, unsigned loade
|
|||||||
|
|
||||||
/* copy any leftover text to the base of the buffer for re-use */
|
/* copy any leftover text to the base of the buffer for re-use */
|
||||||
if (resid > 0) {
|
if (resid > 0) {
|
||||||
memcpy(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid);
|
memmove(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid);
|
||||||
/* enforce null termination */
|
/* enforce null termination */
|
||||||
mixer_text[resid] = '\0';
|
mixer_text[resid] = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user