MessageQueue::pop() transfers ownership of the popped message to the
caller, but many handleInputMessages() implementations only deleted
the message when handleMessage() returned true. When a message was not
handled, ownership had already been transferred from the queue and the
message was leaked.
This was identified while investigating an ASAN leak in the audio
subsystem.
Update the applicable handleInputMessages() implementations to always
delete messages after handleMessage() returns. Unhandled messages are
also logged with the component and message identifier so unexpected
message routing is visible during debugging.
This change:
- Ensures every message popped from a queue has its ownership resolved.
- Prevents leaks when handleMessage() returns false.
- Makes unhandled messages visible instead of silently discarding them.
- Preserves the existing message handling logic and does not require
components to handle message types that are legitimately irrelevant
to them.
The changes are intentionally mechanical and limited to the common
message queue ownership and diagnostic pattern.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Store VOR round-robin turn counters using std::size_t to match the type
returned by std::vector::size() and the type used for vector indexing.
The counters were previously stored as int but converted to unsigned int
when used in rrNextTurn(). Using std::size_t consistently removes the
signed/unsigned mismatch and makes the counter type appropriate for its use
as an index into the round-robin plan.
This also allows cppcheck to correctly reason about the relationship between
the turn counter and the plan size.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Round-robin plans are generated for each available device based on the VOR
channels that can be allocated within the device's available bandwidth. A
device can legitimately produce an empty plan when none of the remaining VOR
frequency combinations fit within that bandwidth.
Empty plans are retained in m_rrPlans because each entry corresponds to a
device and must remain aligned with the per-device m_rrTurnCounters entries.
rrNextTurn() previously assumed every plan contained at least one turn and
unconditionally accessed rrPlan[turnCount]. For an empty plan, the initial
turn count is zero, resulting in an out-of-bounds access.
Skip empty plans in rrNextTurn() while still advancing the device index so
subsequent plans remain aligned with their corresponding turn counters.
This prevents invalid accesses and resolves the out-of-bounds condition
reported by cppcheck.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Create and populate the VOR service report message as before, but delete it
when the feature message queue is not available.
The message is normally transferred to `m_msgQueueToFeature` for ownership,
but when the queue is null there is no owner and the allocated message leaked.
Coverity reported the leak as CID 652338 (`RESOURCE_LEAK`) while analyzing
`VorLocalizerWorker::rrNextTurn()`. Review of the surrounding message queue
usage confirmed that queued messages are owned by the queue, making the
missing-queue path the unhandled ownership case.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
The channel count comparison in getChannelsByDevice() accidentally used
the first plan's channel count for both operands. This caused the comparator
to always treat the channel counts as equal and sort only by bandwidth.
Use the second plan's channel count when comparing RRTurnPlans so plans are
ordered correctly by number of channels before applying the bandwidth
tie-breaker.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Add support for devices such as File Input for which the center
frequency can't be changed.
Use device b/w instead of channel b/w, as the latter may be decimated.