Fix resource ownership and cleanup issues across several SDRangel components. - #2880
Merged
Conversation
Coverity reported a resource leak for the bitcount and errcount writers allocated by opt_writer(). Free them when the FEC decoder helper is destroyed, matching the existing cleanup used by other LeanSDR components. Signed-off-by: Robin Getz <rgetz503@gmail.com>
SWGFreqScannerSettings is newly created without a frequency list, so there is no need to check for or copy into an existing list. Transfer the newly created frequency list directly to the settings object. The previous copy path left the newly allocated QList unowned when an existing frequency list was present. This leaked the list because the assignment copied its contents rather than transferring ownership. This also resolves that resource leak identified by Coverity. Signed-off-by: Robin Getz <rgetz503@gmail.com>
Add a destructor to ObjectMapItem to release its owned m_aircraftState. ObjectMapItem allocates m_aircraftState when aircraft state is present, but had no corresponding cleanup when the map item was destroyed. Coverity reported the allocation as a constructor/destructor resource leak. Signed-off-by: Robin Getz <rgetz503@gmail.com>
Delete the FFT-based RRC filter when RRCHelper is destroyed. RRCHelper allocates m_filterFFT but the destructor did not release it, leaking the filter for every RRCHelper instance. Coverity flagged the missing destructor cleanup as a CTOR_DTOR_LEAK. The existing destructor already releases the FIR filter and sample buffer, making the FFT filter cleanup part of the same ownership path. Signed-off-by: Robin Getz <rgetz503@gmail.com>
Free the bitcount and errcount pipe writers owned by s2_fecdec. The writers are allocated by opt_writer() but were not released when s2_fecdec was destroyed, causing the allocations to leak. Coverity reported a CTOR_DTOR_LEAK in the s2_fecdec constructor, identifying the allocations without corresponding destructor cleanup. Signed-off-by: Robin Getz <rgetz503@gmail.com>
Only allocate `MsgSampleRateCorrection` when a feedback message queue is available. The message was previously allocated before checking `m_autoRWBalance` and `m_feedbackMessageQueue`. When either condition was false, the message was never queued and its allocation was leaked. Coverity CID 652413 reported a `RESOURCE_LEAK` after tracing the allocation from `MsgSampleRateCorrection::create()` to the point where the local pointer went out of scope without being transferred to the feedback queue. Signed-off-by: Robin Getz <rgetz503@gmail.com>
Unload the dynamically loaded VISA library when the VISA object is destroyed and ensure radio astronomy VISA sessions are closed first. Coverity reported a resource leak because `visaLibrary` was loaded with `LoadLibrary`/`dlopen` but was never released. It also identified uninitialized VISA function pointers and the library handle. Initialize the remaining pointers, add platform-specific library cleanup, and close all radio astronomy instrument sessions before releasing the default VISA resource manager. The other VISA users were reviewed to verify that their sessions and default resource managers are also closed before their VISA objects are destroyed. The library is only unloaded when no default resource manager session remains active, avoiding unloading the VISA library while it is still in use. Signed-off-by: Robin Getz <rgetz503@gmail.com>
Add a destructor to s2_deframer to release the pipewriter objects owned by state_out and locktime_out. opt_writer() allocates these pipewriters dynamically when the corresponding output pipe is provided. Without a destructor, the objects were leaked when s2_deframer was destroyed. Coverity reported CTOR_DTOR_LEAK findings for state_out and locktime_out. The existing leansdr code was reviewed and confirmed that other users of opt_writer() explicitly delete the resulting pipewriters in their destructors, so s2_deframer was missing the corresponding cleanup. 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
RRCHelperis destroyed.ObjectMapItem.SWGFreqScannerSettingswithout leaving the allocation unowned.These changes ensure dynamically allocated resources have a corresponding owner and cleanup path, and avoid allocations when ownership cannot be transferred.
The changes address resource leak findings reported by Coverity.