aboutsummaryrefslogtreecommitdiff
path: root/lib/environment.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-03-25 00:38:34 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-03-25 17:16:05 -0400
commit838c0214aa658a93981fb3dcff04c1b9d25983f7 (patch)
tree458f133a323abaad3119721042f17545406d968d /lib/environment.c
parent6f29e5d59217c06d715ac23794b48a743b2bb813 (diff)
downloadspmc-838c0214aa658a93981fb3dcff04c1b9d25983f7.tar.gz
Fix a few memory leaks:
* Cannot free array of manifests successfully though... TODO
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++) {