Skip to content

Commit 8b6aa62

Browse files
phonetic112outfoxxed
authored andcommitted
fix fd leaks in scanPath
use auto
1 parent cd42914 commit 8b6aa62

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/core/desktopentry.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,25 +309,24 @@ void DesktopEntryManager::scanPath(const QDir& dir, const QString& prefix) {
309309
auto entries = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
310310

311311
for (auto& entry: entries) {
312-
if (entry.isDir()) this->scanPath(entry.path(), prefix + dir.dirName() + "-");
312+
if (entry.isDir()) this->scanPath(entry.absoluteFilePath(), prefix + dir.dirName() + "-");
313313
else if (entry.isFile()) {
314314
auto path = entry.filePath();
315315
if (!path.endsWith(".desktop")) {
316316
qCDebug(logDesktopEntry) << "Skipping file" << path << "as it has no .desktop extension";
317317
continue;
318318
}
319319

320-
auto* file = new QFile(path);
321-
322-
if (!file->open(QFile::ReadOnly)) {
320+
auto file = QFile(path);
321+
if (!file.open(QFile::ReadOnly)) {
323322
qCDebug(logDesktopEntry) << "Could not open file" << path;
324323
continue;
325324
}
326325

327326
auto id = prefix + entry.fileName().sliced(0, entry.fileName().length() - 8);
328327
auto lowerId = id.toLower();
329328

330-
auto text = QString::fromUtf8(file->readAll());
329+
auto text = QString::fromUtf8(file.readAll());
331330
auto* dentry = new DesktopEntry(id, this);
332331
dentry->parseEntry(text);
333332

0 commit comments

Comments
 (0)