mirror of https://github.com/xzeldon/htop.git
Initialize buffer for retrieved path
This avoids a warning on GCC 11. Fixes #369
This commit is contained in:
parent
4c4ba9d949
commit
22f8f8000c
|
@ -883,7 +883,7 @@ static void LinuxProcessList_readSecattrData(LinuxProcess* process, openat_arg_t
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LinuxProcessList_readCwd(LinuxProcess* process, openat_arg_t procFd) {
|
static void LinuxProcessList_readCwd(LinuxProcess* process, openat_arg_t procFd) {
|
||||||
char pathBuffer[PATH_MAX + 1];
|
char pathBuffer[PATH_MAX + 1] = {0};
|
||||||
|
|
||||||
#if defined(HAVE_READLINKAT) && defined(HAVE_OPENAT)
|
#if defined(HAVE_READLINKAT) && defined(HAVE_OPENAT)
|
||||||
ssize_t r = readlinkat(procFd, "cwd", pathBuffer, sizeof(pathBuffer) - 1);
|
ssize_t r = readlinkat(procFd, "cwd", pathBuffer, sizeof(pathBuffer) - 1);
|
||||||
|
@ -892,6 +892,7 @@ static void LinuxProcessList_readCwd(LinuxProcess* process, openat_arg_t procFd)
|
||||||
xSnprintf(filename, sizeof(filename), "%s/cwd", procFd);
|
xSnprintf(filename, sizeof(filename), "%s/cwd", procFd);
|
||||||
ssize_t r = readlink(filename, pathBuffer, sizeof(pathBuffer) - 1);
|
ssize_t r = readlink(filename, pathBuffer, sizeof(pathBuffer) - 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
free(process->cwd);
|
free(process->cwd);
|
||||||
process->cwd = NULL;
|
process->cwd = NULL;
|
||||||
|
|
Loading…
Reference in New Issue