From 2cd4ad0979ffd3a351bedd69e0ac76dfc6a2e383 Mon Sep 17 00:00:00 2001 From: jrd Date: Wed, 29 Jul 2026 02:59:13 +0000 Subject: [PATCH] Fix #1083: free CJamRecorder if Init() fails SetRecordingDir() unconditionally news a CJamRecorder, then only wires moveToThread/deleteLater cleanup inside the bRecorderInitialised branch. If Init() fails (e.g. unwritable directory), the freshly-new'd object is orphaned: no thread affinity, no deleteLater connection, no destructor anywhere else to catch it. Free it immediately in the failure branch. The next SetRecordingDir() call overwrites pJamRecorder, so without this fix the leak repeats on every failed recording-dir change. --- src/recorder/jamcontroller.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/recorder/jamcontroller.cpp b/src/recorder/jamcontroller.cpp index 2c277fe0f3..c4d8de88e7 100644 --- a/src/recorder/jamcontroller.cpp +++ b/src/recorder/jamcontroller.cpp @@ -116,6 +116,12 @@ void CJamController::SetRecordingDir ( QString newRecordingDir, int iServerFrame bRecorderInitialised = ( strRecorderErrMsg == QString() ); bEnableRecording = bRecorderInitialised && !bDisableRecording; + if ( !bRecorderInitialised ) + { + delete pJamRecorder; // Init() failed: never moved to thread / never + pJamRecorder = nullptr; // wired to deleteLater, so free it here (#1083) + } + qInfo() << qUtf8Printable ( QString ( "Recording state: %1" ).arg ( bEnableRecording ? "enabled" : "disabled" ) ); } else