aboutsummaryrefslogtreecommitdiff
path: root/tar
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 23:39:26 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-28 00:06:07 +0200
commit1cf9256b38465989ac2fedfdb8a6aebeeeb628e4 (patch)
tree39584073da0bf13442ec0562eff9fd97e299dacc /tar
parentfd607ef164588afddf93139a1b76bf8bffcce078 (diff)
Fix memory leaks in sqfs2tar error paths
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar')
-rw-r--r--tar/sqfs2tar.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c
index 10c4d24..9001c5a 100644
--- a/tar/sqfs2tar.c
+++ b/tar/sqfs2tar.c
@@ -213,19 +213,21 @@ static int get_xattrs(const sqfs_inode_generic_t *inode, tar_xattr_t **out)
for (i = 0; i < desc.count; ++i) {
if (sqfs_xattr_reader_read_key(xr, &key)) {
fputs("Error reading xattr key\n", stderr);
- return -1;
+ goto fail;
}
if (sqfs_xattr_reader_read_value(xr, key, &value)) {
fputs("Error reading xattr value\n", stderr);
free(key);
- return -1;
+ goto fail;
}
ent = calloc(1, sizeof(*ent) + strlen((const char *)key->key) +
value->size + 2);
if (ent == NULL) {
perror("creating xattr entry");
+ free(key);
+ free(value);
goto fail;
}
@@ -275,8 +277,10 @@ static int write_tree_dfs(const sqfs_tree_node_t *n)
inode_stat(n, &sb);
if (!no_xattr) {
- if (get_xattrs(n->inode, &xattr))
+ if (get_xattrs(n->inode, &xattr)) {
+ free(name);
return -1;
+ }
}
target = S_ISLNK(sb.st_mode) ? n->inode->slink_target : NULL;