Skip to content

Commit

Permalink
Fix memory leaks in pax writer when handing mac metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggcueroad committed Dec 2, 2012
1 parent 3bfbc99 commit 1c7d5f3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libarchive/archive_write_set_format_pax.c
Expand Up @@ -647,8 +647,10 @@ archive_write_pax_header(struct archive_write *a,
oname = archive_entry_pathname(entry_original); oname = archive_entry_pathname(entry_original);
name_length = strlen(oname); name_length = strlen(oname);
name = malloc(name_length + 3); name = malloc(name_length + 3);
if (name == NULL) { if (name == NULL || extra == NULL) {
/* XXX error message */ /* XXX error message */
archive_entry_free(extra);
free(name);
return (ARCHIVE_FAILED); return (ARCHIVE_FAILED);
} }
strcpy(name, oname); strcpy(name, oname);
Expand Down Expand Up @@ -687,6 +689,7 @@ archive_write_pax_header(struct archive_write *a,


/* Recurse to write the special copyfile entry. */ /* Recurse to write the special copyfile entry. */
r = archive_write_pax_header(a, extra); r = archive_write_pax_header(a, extra);
archive_entry_free(extra);
if (r < ARCHIVE_WARN) if (r < ARCHIVE_WARN)
return (r); return (r);
if (r < ret) if (r < ret)
Expand Down

0 comments on commit 1c7d5f3

Please sign in to comment.