1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Don't forget to free a string allocated by strdup where necessary.

Found by:	Coverity Prevent
Coverity ID:	CID 3132
This commit is contained in:
Colin Percival 2007-05-19 05:09:09 +00:00
parent 12c95a2554
commit a7e2f06359
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=169733

View File

@ -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);
}
}