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:
parent
15bdc412d8
commit
1a5e79cbeb
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user