Skip to content
Snippets Groups Projects
Commit 6927fcb5 authored by Lorenz Meier's avatar Lorenz Meier
Browse files

Mixer test: Fix string termination corner case

parent 9605507c
No related branches found
No related tags found
No related merge requests found
......@@ -297,10 +297,10 @@ bool MixerTest::load_mixer(const char *filename, const char *buf, unsigned loade
ut_compare("empty buffer load", empty_load, 0);
/* FIRST mark the mixer as invalid */
/* THEN actually delete it */
/* reset, load in chunks */
mixer_group.reset();
char mixer_text[PX4IO_MAX_MIXER_LENGHT]; /* large enough for one mixer */
unsigned mixer_text_length = 0;
unsigned transmitted = 0;
......@@ -333,6 +333,8 @@ 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 */
if (resid > 0) {
memcpy(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid);
/* enforce null termination */
mixer_text[resid] = '\0';
}
mixer_text_length = resid;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment