aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libarchive/archive_write_set_format_shar.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libarchive/archive_write_set_format_shar.c b/lib/libarchive/archive_write_set_format_shar.c
index 5751b3e00ca8..3d6729cc90d5 100644
--- a/lib/libarchive/archive_write_set_format_shar.c
+++ b/lib/libarchive/archive_write_set_format_shar.c
@@ -213,11 +213,14 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
/* Try to avoid a lot of redundant mkdir commands. */
if (strcmp(p, ".") == 0) {
/* Don't try to "mkdir ." */
+ free(p);
} else if (shar->last_dir == NULL) {
ret = shar_printf(a,
"mkdir -p %s > /dev/null 2>&1\n", p);
- if (ret != ARCHIVE_OK)
+ if (ret != ARCHIVE_OK) {
+ free(p);
return (ret);
+ }
shar->last_dir = p;
} else if (strcmp(p, shar->last_dir) == 0) {
/* We've already created this exact dir. */
@@ -229,11 +232,15 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
} else {
ret = shar_printf(a,
"mkdir -p %s > /dev/null 2>&1\n", p);
- if (ret != ARCHIVE_OK)
+ if (ret != ARCHIVE_OK) {
+ free(p);
return (ret);
+ }
free(shar->last_dir);
shar->last_dir = p;
}
+ } else {
+ free(p);
}
}