From 6d041cc856340b0e2386f94bea53d9e68a0beb9b Mon Sep 17 00:00:00 2001 From: Juli Mallett Date: Wed, 5 Jun 2002 01:58:36 +0000 Subject: [PATCH] To comply with SUSv3, duplicate the variable contents for each given format, so that multiple -ovar=header lines do not overwrite eachother. This means that ps -ouser=USERNAME -ouser=WHO would now possibly print: USERNAME WHO juli juli Whereas before it would be: WHO WHO juli juli --- bin/ps/keyword.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 0e4241a33232..7c846914413a 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -246,7 +246,10 @@ parsefmt(const char *p) continue; if ((vent = malloc(sizeof(struct varent))) == NULL) err(1, NULL); - vent->var = v; + vent->var = malloc(sizeof(*vent->var)); + if (vent->var == NULL) + err(1, NULL); + memcpy(vent->var, v, sizeof(*vent->var)); vent->next = NULL; if (vhead == NULL) vhead = vtail = vent;