Make def:<var> compatible between "static" and "dynamic" vars.
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Tue, 26 May 2020 10:28:43 +0000 (12:28 +0200)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Tue, 26 May 2020 12:59:06 +0000 (14:59 +0200)
Some variables are simple pointers to internal memory (e.g.
vtype_stringptr), other variables are dynamically filled with content
(e.g. vtype_string_func).

The static variables contain "" if they're not defined yet.
At least on dynamic variable (recipients, backed by fn_recipients())
returned NULL instead of "", which lead to unexpected results on
def:recipients.

To keep the functions usable in places where it makes sense to return
NULL and "" as distinct values, I didn't touch the functions, but the
evaluation logic in find_variable().

src/src/expand.c

index 2c29c26d538550801ae7574e597b588860e17fd0..26f7f10acfed2bb61ba423c60014927410ef2af5 100644 (file)
@@ -2066,7 +2066,8 @@ switch (vp->type)
   case vtype_string_func:
     {
     stringptr_fn_t * fn = (stringptr_fn_t *) val;
-    return fn();
+    uschar* s = fn();
+    return s ? s : US"";
     }
 
   case vtype_pspace: