From 2af2a33a5d9e938915cf890242b69e6f44f8dafc Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sat, 23 Nov 2019 11:19:34 +0900 Subject: Add a check for the readlink result in processNameByPid() This fixes release build on Linux Change-Id: I67fb4b01bf578db625343b50b06c0d1a0457999c Reviewed-by: Richard Weickelt Reviewed-by: Christian Kandeler --- src/lib/corelib/tools/processutils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/corelib/tools/processutils.cpp b/src/lib/corelib/tools/processutils.cpp index 04a061e0c..b27592f88 100644 --- a/src/lib/corelib/tools/processutils.cpp +++ b/src/lib/corelib/tools/processutils.cpp @@ -92,7 +92,8 @@ QString processNameByPid(qint64 pid) char buf[PATH_MAX]; memset(buf, 0, sizeof(buf)); sprintf(exePath, "/proc/%lld/exe", pid); - readlink(exePath, buf, sizeof(buf)); + if (readlink(exePath, buf, sizeof(buf)) < 0) + return {}; return FileInfo::fileName(QString::fromUtf8(buf)); #elif defined(Q_OS_BSD4) # if defined(Q_OS_NETBSD) -- cgit v1.2.3