From 4f7527f8e49276894751a9b100e68bc46568bb85 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sat, 19 May 2018 02:39:48 +0800 Subject: exec: Do not allocate stack string in padvance Many callers of padvance immediately free the allocated string so this patch moves the stalloc call to the caller. Instead of returning the allocated string, padvance now returns the length to allocate (this may be longer than the actual string length, even including the NUL). For the case where we would previously return NULL, we now return -1. Signed-off-by: Herbert Xu --- src/mail.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/mail.c') diff --git a/src/mail.c b/src/mail.c index 02e07f7..7f9e49d 100644 --- a/src/mail.c +++ b/src/mail.c @@ -77,9 +77,12 @@ chkmail(void) setstackmark(&smark); mpath = mpathset() ? mpathval() : mailval(); for (mtp = mailtime; mtp < mailtime + MAXMBOXES; mtp++) { - p = padvance(&mpath, nullstr); - if (p == NULL) + int len; + + len = padvance(&mpath, nullstr); + if (!len) break; + p = stackblock(); if (*p == '\0') continue; for (q = p ; *q ; q++); -- cgit 1.4.1