videoLIVE555Source:
- _stop() tore the stream down on the caller's thread while the live555
thread was still inside doEventLoop(), and deleted the RTSP client, the
environment and the scheduler under the running loop. Now it ends the
loop, joins the thread, then closes what is left on its own thread.
- shutdownStream() no longer deletes the scheduler/environment (a second
shutdown, e.g. _close() then the destructor or a live555 callback then
the destructor, used them after they were freed). Only the destructor
frees them, once. A second shutdown is a no-op.
- m_pRtspClient and the other pointers are initialised: a source that was
never opened, or failed to open, shut down a random pointer.
- The event-loop flag is reset in _open(), not at thread start, so a stop
issued before the thread ran is not lost.
- shutdownStream closes the subsession sinks and sends TEARDOWN, as
live555 testRTSPClient does. The sinks were never closed and leaked.
- continueAfterPLAY frees resultString.
DummySink:
- Every pointer is NULL-initialised before the constructor can return
early. The destructor freed an uninitialised m_pFrame when the codec
was not found or in stream-proxy mode.
- Decode resources are created whenever DECODE_FRAMES is set, also
together with STREAM_PROXY (deviceNodeCamera uses both). They were
used uninitialised. Decoding is skipped if any of them is missing.
- m_sAvPkt is zeroed (av_packet_unref() frees opaque_ref/side_data).
- The destructor frees the frames, the RGB buffer, the scaler, the codec
context, the output format context and dictionary, and m_pH264. The
trailer is written only after a written header.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16