Fix potential null pointer deref if Mavlink start fails before task_main loop

LL_APPEND is called just before the loop spins up but various error conditions can cause the task to exit before then.
When that happens Mavlink::start_helper calls delete on the instance which tries to prune it from the global list.
If this is the first Mavlink instance to attempt starting the list head is null and we hardfault in the Mavlink dtor.

Only call LL_DELETE after checking the list head for a null pointer.
This commit is contained in:
Nate Weibley 2015-05-13 11:19:29 -04:00
parent 66b87ac761
commit b4e7b041ca

View File

@ -249,7 +249,9 @@ Mavlink::~Mavlink()
} while (_task_running);
}
LL_DELETE(_mavlink_instances, this);
if (_mavlink_instances) {
LL_DELETE(_mavlink_instances, this);
}
}
void