summaryrefslogtreecommitdiff
path: root/src/expand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/expand.c')
-rw-r--r--src/expand.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/expand.c b/src/expand.c
index 01fff81e..533e7dfa 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -226,6 +226,7 @@ char *
expand_variable_output (char *ptr, const char *name, size_t length)
{
struct variable *v;
+ unsigned int recursive;
char *value;
v = lookup_variable (name, length);
@@ -237,11 +238,14 @@ expand_variable_output (char *ptr, const char *name, size_t length)
if (!v || (v->value[0] == '\0' && !v->append))
return ptr;
- value = v->recursive ? recursively_expand (v) : v->value;
+ /* Remember this since expansion could change it. */
+ recursive = v->recursive;
+
+ value = recursive ? recursively_expand (v) : v->value;
ptr = variable_buffer_output (ptr, value, strlen (value));
- if (v->recursive)
+ if (recursive)
free (value);
return ptr;