summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2007-05-19 05:09:09 +0000
committercperciva <cperciva@FreeBSD.org>2007-05-19 05:09:09 +0000
commit1a5e79cbeb29368e20f07345e37c817a15558081 (patch)
tree3919a9733e724cc36a03ff02b01ddcb29abef245 /lib
parent15bdc412d800701a554f5c50c4aae7b975a48332 (diff)
downloadFreeBSD-src-1a5e79cbeb29368e20f07345e37c817a15558081.zip
FreeBSD-src-1a5e79cbeb29368e20f07345e37c817a15558081.tar.gz
Don't forget to free a string allocated by strdup where necessary.
Found by: Coverity Prevent Coverity ID: CID 3132
Diffstat (limited to 'lib')
-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 5751b3e..3d6729c 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);
}
}
OpenPOWER on IntegriCloud