kman: fix possible null-pointer dereference

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-03-11 21:02:33 +02:00
parent e87e117174
commit 2345dd7b51

View file

@ -44,9 +44,6 @@ class KManLister : public QThread {
public: public:
KManLister(QObject *parent = Q_NULLPTR); KManLister(QObject *parent = Q_NULLPTR);
QList<QByteArray> m_paths;
bool m_interrupt;
public Q_SLOTS: public Q_SLOTS:
void slotScan(QString path); void slotScan(QString path);
@ -58,7 +55,9 @@ class KManLister : public QThread {
virtual void run(); virtual void run();
private: private:
QList<QByteArray> m_paths;
QFileSystemWatcher m_watcher; QFileSystemWatcher m_watcher;
bool m_interrupt;
}; };
KManLister::KManLister(QObject *parent) KManLister::KManLister(QObject *parent)
@ -363,10 +362,12 @@ QString KManMainWindow::manContent(const QString path) {
QByteArray content; QByteArray content;
if (path.endsWith(".gz") || path.endsWith(".bz2") || path.endsWith(".xz")) { if (path.endsWith(".gz") || path.endsWith(".bz2") || path.endsWith(".xz")) {
QIODevice *archivedevice = KFilterDev::deviceForFile(path); QIODevice *archivedevice = KFilterDev::deviceForFile(path);
if (archivedevice && archivedevice->open(QFile::ReadOnly)) { if (archivedevice) {
content = archivedevice->readAll(); if (archivedevice->open(QFile::ReadOnly)) {
content = archivedevice->readAll();
}
archivedevice->deleteLater();
} }
archivedevice->deleteLater();
} else { } else {
if (pathfile.open(QFile::ReadOnly)) { if (pathfile.open(QFile::ReadOnly)) {
content = pathfile.readAll(); content = pathfile.readAll();