Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlanManager: prevent memory leak when writing mission items to vehicle #12524

Merged
merged 2 commits into from
Mar 1, 2025

Conversation

AsensioL
Copy link
Contributor

Prevent MissionIteam leakage when uploading mission to vehicle

Description

When uploading a mission to a vehicle, the MissionController takes its VisualMissionItems and copies them into a temporary QList<MissionItem*>.

Detailed explanation:

  1. This starts at MissionController::sendToVehicle, which calls MissionController::sendItemsToVehicle where MissionItems are allocated by ...
  2. calling MissionController::_convertToMissionItems, which itself ...
  3. defers to the pure virtual function VisualMissionItem::appendMissionItems, where the implementation depends on the type of VisualMissionItem, but they all
  4. use new, and set the VisualMissionItem's parent to the Vehicle* instance.

When the connected vehicle is one that skips the first MissionItem (see implementation of PlanManager::writeMissionItems) then, the first MissionItem* is never moved to the PlanManager::_writeMissionItems and is leaked until the Vehicle* instance is destroyed (which kicks in Qt's cleaning broom).

Checklist:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@DonLakeFlyer
Copy link
Contributor

Yup, thanks for the fix.

@DonLakeFlyer DonLakeFlyer merged commit 70bb7f3 into mavlink:master Mar 1, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants