From 46c1c9de65b5cb04ff957238763211b4d19bee0b Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Wed, 27 Sep 2023 08:00:20 +0300 Subject: [PATCH] Fix memory leaks * Fixes a couple of memory leaks (although not dangerous in practice, since we are talking about objects with a lifetime up to the end of the application) * Fixes heap use after free PR #19650. Closes #19632. --- src/base/http/requestparser.cpp | 2 +- src/base/torrentfileswatcher.cpp | 2 +- src/gui/lineedit.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/http/requestparser.cpp b/src/base/http/requestparser.cpp index c513e0018..8ee551931 100644 --- a/src/base/http/requestparser.cpp +++ b/src/base/http/requestparser.cpp @@ -212,7 +212,7 @@ bool RequestParser::parseRequestLine(const QString &line) if (sepPos >= 0) { - const QByteArrayView query = url.mid(sepPos + 1); + const QByteArrayView query = QByteArrayView(url).mid(sepPos + 1); // [rfc3986] 2.4 When to Encode or Decode // URL components should be separated before percent-decoding diff --git a/src/base/torrentfileswatcher.cpp b/src/base/torrentfileswatcher.cpp index c8ec3e9d6..1cfcd7a4b 100644 --- a/src/base/torrentfileswatcher.cpp +++ b/src/base/torrentfileswatcher.cpp @@ -159,7 +159,7 @@ void TorrentFilesWatcher::initWorker() connect(m_asyncWorker, &TorrentFilesWatcher::Worker::torrentFound, this, &TorrentFilesWatcher::onTorrentFound); m_asyncWorker->moveToThread(m_ioThread.get()); - connect(m_ioThread.get(), &QThread::finished, this, [this] { delete m_asyncWorker; }); + connect(m_ioThread.get(), &QObject::destroyed, this, [this] { delete m_asyncWorker; }); m_ioThread->start(); for (auto it = m_watchedFolders.cbegin(); it != m_watchedFolders.cend(); ++it) diff --git a/src/gui/lineedit.cpp b/src/gui/lineedit.cpp index b6ad0af76..f388fab60 100644 --- a/src/gui/lineedit.cpp +++ b/src/gui/lineedit.cpp @@ -38,7 +38,7 @@ LineEdit::LineEdit(QWidget *parent) : QLineEdit(parent) { - auto *action = new QAction(UIThemeManager::instance()->getIcon(u"edit-find"_s), QString()); + auto *action = new QAction(UIThemeManager::instance()->getIcon(u"edit-find"_s), QString(), this); addAction(action, QLineEdit::LeadingPosition); setClearButtonEnabled(true);