AP_Mission: get_item: ensure returned item is clean #29038
+11
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mission does not fill in all fields of the returned item, this means you can get random data. This results in getting bad data via misison ftp or scripting. The mavlink mission item protocol does not use this method. The other mission ftp types are OK because they always fill in the full set of information.
To reproduce, upload a misison and then read it back again. For example before.txt. Testing shown for SITL but the bug also exists on real hardware.
This is what we upload:
This is what we read back on master:
With the fix we get the same as what is written:
This only shows up in the x,y,z fields of a item without location because the other fields are defaulted here:
ardupilot/libraries/AP_Mission/AP_Mission.cpp
Lines 1574 to 1585 in 6efe210
A alternate (or complementary) fix would be to also set default values for the x,y and z values there.