library: fix a potential error relating to 'exe' logic

After 'errno' management was standardized, a couple of
fields were added to the <pids> api. Only 1 (PIDS_EXE)
involved dynamic memory and, unfortunately, it did not
conform to that expected normalized ENOMEM convention.

Reference(s):
. Jun 2018, added 'exe' to library
commit ad4269f118
. Nov 2017, standardized 'errno' management
commit 06be33b43e

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-12-22 00:00:00 -06:00 committed by Craig Small
parent fd64b91d09
commit e76c773561

View File

@ -1118,8 +1118,10 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
if (flags & PROC_FILL_LUID) // value the login user id
p->luid = login_uid(path);
if (flags & PROC_FILL_EXE)
p->exe = readlink_exe(path);
if (flags & PROC_FILL_EXE) {
if (!(p->exe = readlink_exe(path)))
rc += 1;
}
if (rc == 0) return p;
errno = ENOMEM;
@ -1211,8 +1213,10 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, proc_t *restrict cons
if (flags & PROC_FILLSYSTEMD) // get sd-login.h stuff
rc += sd2proc(t);
if (flags & PROC_FILL_EXE)
t->exe = readlink_exe(path);
if (flags & PROC_FILL_EXE) {
if (!(t->exe = readlink_exe(path)))
rc += 1;
}
#ifdef FALSE_THREADS
}
#endif