aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/environment.c14
-rw-r--r--lib/fs.c1
-rw-r--r--lib/manifest.c16
3 files changed, 22 insertions, 9 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++) {
diff --git a/lib/fs.c b/lib/fs.c
index d920248..e285916 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -417,6 +417,7 @@ int mkdirs(const char *_path, mode_t mode) {
}
}
split_free(parts);
+ free(path);
return result;
}
diff --git a/lib/manifest.c b/lib/manifest.c
index 72919ff..239ec69 100644
--- a/lib/manifest.c
+++ b/lib/manifest.c
@@ -159,7 +159,9 @@ Manifest *manifest_from(const char *package_dir) {
*/
void manifest_free(Manifest *info) {
for (size_t i = 0; i < info->records; i++) {
- manifest_package_free(info->packages[i]);
+ if (info->packages[i] != NULL) {
+ manifest_package_free(info->packages[i]);
+ }
}
free(info);
}
@@ -169,8 +171,14 @@ void manifest_free(Manifest *info) {
* @param info `ManifestPackage`
*/
void manifest_package_free(ManifestPackage *info) {
+ if (info->requirements == NULL) {
+ return;
+ }
+
for (size_t i = 0; i < info->requirements_records; i++) {
- free(info->requirements[i]);
+ if (info->requirements[i] != NULL) {
+ free(info->requirements[i]);
+ }
}
free(info->requirements);
free(info);
@@ -559,7 +567,9 @@ ManifestPackage *manifest_package_copy(const ManifestPackage *manifest) {
*/
void manifestlist_free(ManifestList *pManifestList) {
for (size_t i = 0; i < pManifestList->num_inuse; i++) {
- manifest_free(pManifestList->data[i]);
+ if (pManifestList->data[i] != NULL) {
+ manifest_free(pManifestList->data[i]);
+ }
}
free(pManifestList->data);
free(pManifestList);