From 26ab9ae143051ab9ec59c9460f19bfb7c6f80140 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 6 Jun 2018 00:00:00 -0500 Subject: [PATCH] ps: ensure functions not called prior to setREL macros Under newlib design, ps must loop though all potential print functions so as to gather the appropriate enum's while establishing the 'relative' equivalent. The keys to the setREL/chkREL macros are a NULL 'outbuf' param. It's imperative that no other functions be called with that NULL value. Unfortunately, several instances were found where this was violated. They are now corrected! Signed-off-by: Jim Warner --- ps/output.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ps/output.c b/ps/output.c index 28697ccb..74260a0e 100644 --- a/ps/output.c +++ b/ps/output.c @@ -274,8 +274,9 @@ Modifications to the arguments are not shown. static int pr_args(char *restrict const outbuf, const proc_t *restrict const pp){ char *endp = outbuf; int rightward = max_rightward; - int fh = forest_helper(outbuf); + int fh; setREL2(CMDLINE,ENVIRON) + fh = forest_helper(outbuf); endp += fh; rightward -= fh; endp += escaped_copy(endp, rSv(CMDLINE, str, pp), OUTBUF_SIZE, &rightward); @@ -297,8 +298,9 @@ setREL2(CMDLINE,ENVIRON) static int pr_comm(char *restrict const outbuf, const proc_t *restrict const pp){ char *endp = outbuf; int rightward = max_rightward; - int fh = forest_helper(outbuf); + int fh; setREL3(CMD,CMDLINE,ENVIRON) + fh = forest_helper(outbuf); endp += fh; rightward -= fh; if(unix_f_option) @@ -335,8 +337,9 @@ setREL1(CGROUP) static int pr_fname(char *restrict const outbuf, const proc_t *restrict const pp){ char *endp = outbuf; int rightward = max_rightward; - int fh = forest_helper(outbuf); + int fh; setREL1(CMD) + fh = forest_helper(outbuf); endp += fh; rightward -= fh; if (rightward>8) /* 8=default, but forest maybe feeds more */