aboutsummaryrefslogtreecommitdiff
path: root/lib/environment.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/environment.c')
-rw-r--r--lib/environment.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/environment.c b/lib/environment.c
index d9bfe51..3144982 100644
--- a/lib/environment.c
+++ b/lib/environment.c
@@ -250,18 +250,20 @@ char *runtime_expand_var(RuntimeEnv *env, const char *input) {
const char delim = '$';
const char *delim_literal = "$$";
const char *escape = "\\";
- char *expanded = calloc(BUFSIZ, sizeof(char));
- if (expanded == NULL) {
- perror("could not allocate runtime_expand_var buffer");
- fprintf(SYSERROR);
- return NULL;
- }
+ char *expanded = NULL;
// If there's no environment variables to process return a copy of the input string
if (strchr(input, delim) == NULL) {
return strdup(input);
}
+ expanded = calloc(BUFSIZ, sizeof(char));
+ if (expanded == NULL) {
+ perror("could not allocate runtime_expand_var buffer");
+ fprintf(SYSERROR);
+ return NULL;
+ }
+
// Parse the input string
size_t i;
for (i = 0; i < strlen(input); i++) {