From 4d498eee0ba5a7f3a4bc1d168ba7f68b82f746a9 Mon Sep 17 00:00:00 2001 From: jixiaoxu Date: Thu, 13 Oct 2022 17:37:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dinotify-watch=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F=EF=BC=9B=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86Fortify=E6=A3=80=E6=B5=8B=E4=BB=A3=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/index/inotify-watch.cpp | 3 ++- libsearch/parser/binary-parser.cpp | 2 +- .../convert-winid-to-desktop.cpp | 16 ++++++++-------- .../convert-winid-to-desktop.h | 8 ++++---- .../dirwatcher/dir-watcher.cpp | 3 ++- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/libsearch/index/inotify-watch.cpp b/libsearch/index/inotify-watch.cpp index c463551..7a02f15 100644 --- a/libsearch/index/inotify-watch.cpp +++ b/libsearch/index/inotify-watch.cpp @@ -249,8 +249,8 @@ void InotifyWatch::run() if(i < len ) { qDebug() << "fork"; slotEvent(buf, len); - free(buf); } + free(buf); --FileUtils::indexStatus; } else if(rc < 0) { // error @@ -412,6 +412,7 @@ void InotifyWatch::eventProcess(int socket) } if(i >= len) { qDebug() << "There is nothing to do!"; + free(buffer); return; } eventProcess(buffer, len); diff --git a/libsearch/parser/binary-parser.cpp b/libsearch/parser/binary-parser.cpp index 0b2376c..a374f4b 100644 --- a/libsearch/parser/binary-parser.cpp +++ b/libsearch/parser/binary-parser.cpp @@ -4486,7 +4486,7 @@ static ULONG ulReadLong(FILE *pFile, ULONG ulOffset) { UCHAR aucBytes[4]; if(!bReadBytes(aucBytes, 4, ulOffset, pFile)) { - return -1; + return ULONG_MAX; } return ulGetLong(0, aucBytes); } /* end of ulReadLong */ diff --git a/ukui-search-app-data-service/convert-winid-to-desktop.cpp b/ukui-search-app-data-service/convert-winid-to-desktop.cpp index 6bf8b10..eaa32c3 100755 --- a/ukui-search-app-data-service/convert-winid-to-desktop.cpp +++ b/ukui-search-app-data-service/convert-winid-to-desktop.cpp @@ -42,7 +42,7 @@ QString ConvertWinidToDesktop::tranIdToDesktop(WId id) QString ConvertWinidToDesktop::confirmDesktopFile(KWindowInfo info) { - QString desktopFilePath = nullptr; + QString desktopFilePath = QString(); QDir dir = QDir(DESKTOP_FILE_PATH); QFileInfoList list = dir.entryInfoList(); //跳过 ./ 和 ../ 目录 @@ -117,7 +117,7 @@ QString ConvertWinidToDesktop::searchAndroidApp(KWindowInfo info) return fileInfo.filePath(); } } - return nullptr; + return QString(); } QString ConvertWinidToDesktop::searchFromEnviron(KWindowInfo info, QFileInfoList list) @@ -128,7 +128,7 @@ QString ConvertWinidToDesktop::searchFromEnviron(KWindowInfo info, QFileInfoList file.close(); QList list_BA = BA.split('\0'); - QString desktopFilePath = nullptr; + QString desktopFilePath = QString(); for (int i = 0; i < list_BA.length(); i++) { if (list_BA.at(i).startsWith("GIO_LAUNCHED_DESKTOP_FILE=")) { desktopFilePath = list_BA.at(i); @@ -165,7 +165,7 @@ QString ConvertWinidToDesktop::compareClassName(QFileInfoList list) return fileInfo.filePath(); } } - return nullptr; + return QString(); } QString ConvertWinidToDesktop::compareCmdExec(QFileInfoList list) @@ -193,7 +193,7 @@ QString ConvertWinidToDesktop::compareCmdExec(QFileInfoList list) return fileInfo.filePath(); } } - return nullptr; + return QString(); } //最后的匹配策略汇总 @@ -230,7 +230,7 @@ QString ConvertWinidToDesktop::compareCmdName(QFileInfoList list) return fileInfo.filePath(); } } - return nullptr; + return QString(); } QString ConvertWinidToDesktop::compareDesktopClass(QFileInfoList list) @@ -251,7 +251,7 @@ QString ConvertWinidToDesktop::compareDesktopClass(QFileInfoList list) return fileInfo.filePath(); } } - return nullptr; + return QString(); } QString ConvertWinidToDesktop::containsName(QFileInfoList list) @@ -275,7 +275,7 @@ QString ConvertWinidToDesktop::containsName(QFileInfoList list) return fileInfo.filePath(); } } - return nullptr; + return QString(); } //执行头文件中宏定义写好的终端指令获取对应的Exec字段 diff --git a/ukui-search-app-data-service/convert-winid-to-desktop.h b/ukui-search-app-data-service/convert-winid-to-desktop.h index 5cb964c..38c30ca 100755 --- a/ukui-search-app-data-service/convert-winid-to-desktop.h +++ b/ukui-search-app-data-service/convert-winid-to-desktop.h @@ -57,10 +57,10 @@ private: ConvertWinidToDesktop& operator =(const ConvertWinidToDesktop&) = delete; ~ConvertWinidToDesktop(); - QString m_classClass = nullptr; - QString m_className = nullptr; - QString m_statusName = nullptr; - QString m_cmdLine = nullptr; + QString m_classClass = QString(); + QString m_className = QString(); + QString m_statusName = QString(); + QString m_cmdLine = QString(); QString confirmDesktopFile(KWindowInfo info); QString searchFromEnviron(KWindowInfo info, QFileInfoList list); diff --git a/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp b/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp index c66156a..5bc1007 100644 --- a/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp +++ b/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp @@ -79,8 +79,9 @@ void DirWatcher::handleIndexItemAppend(const QString &path, QStringList &blackLi //处理添加路径非根目录时,要添加索引的路径与已索引路径为父子关系的情况 if (path != "/") { + QString indexablePath; for (int i = 0; i < m_indexableDirList.length(); i++) { - const QString indexablePath = m_indexableDirList.at(i); + indexablePath = m_indexableDirList.at(i); if (path.startsWith(indexablePath + "/")) { qCritical() << QString("The parent of the path:%1 has been added.").arg(path); return;