diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-06 19:25:12 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-06 19:25:12 +0200 |
commit | 7fb91aa5872a79ab94a9adae6ca72f1b1d0f8e36 (patch) | |
tree | e5091822a0b5a3b4a585c5ba19f99853f23b003f | |
parent | 41ddda0c732d916a6962c54a3a974a8b753f194b (diff) |
Fix resource leaks reported by coverity
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r-- | lib/sqfs/read_inode.c | 8 | ||||
-rw-r--r-- | lib/sqfs/xattr_writer.c | 1 | ||||
-rw-r--r-- | lib/sqfshelper/serialize_fstree.c | 8 | ||||
-rw-r--r-- | mkfs/dirscan.c | 2 |
4 files changed, 14 insertions, 5 deletions
diff --git a/lib/sqfs/read_inode.c b/lib/sqfs/read_inode.c index f877da1..7e59445 100644 --- a/lib/sqfs/read_inode.c +++ b/lib/sqfs/read_inode.c @@ -263,8 +263,10 @@ static int read_inode_dir_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base, for (i = 0; i <= dir.inodex_count; ++i) { err = sqfs_meta_reader_read(ir, &ent, sizeof(ent)); - if (err) + if (err) { + free(out); return err; + } SWAB32(ent.start_block); SWAB32(ent.index); @@ -289,8 +291,10 @@ static int read_inode_dir_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base, err = sqfs_meta_reader_read(ir, out->extra + index_used, ent.size + 1); - if (err) + if (err) { + free(out); return err; + } } out->num_dir_idx_bytes = index_used; diff --git a/lib/sqfs/xattr_writer.c b/lib/sqfs/xattr_writer.c index 25fee80..22d4639 100644 --- a/lib/sqfs/xattr_writer.c +++ b/lib/sqfs/xattr_writer.c @@ -359,6 +359,7 @@ static sqfs_s32 write_value(sqfs_meta_writer_t *mw, const char *value_str, if (err) goto fail; + free(value); return sizeof(vent) + size; fail: free(value); diff --git a/lib/sqfshelper/serialize_fstree.c b/lib/sqfshelper/serialize_fstree.c index 05a9d3a..c2d956f 100644 --- a/lib/sqfshelper/serialize_fstree.c +++ b/lib/sqfshelper/serialize_fstree.c @@ -175,13 +175,17 @@ int sqfs_serialize_fstree(const char *filename, sqfs_file_t *file, ret = sqfs_id_table_id_to_index(idtbl, n->uid, &inode->base.uid_idx); - if (ret) + if (ret) { + free(inode); goto out; + } ret = sqfs_id_table_id_to_index(idtbl, n->gid, &inode->base.gid_idx); - if (ret) + if (ret) { + free(inode); goto out; + } sqfs_meta_writer_get_position(im, &block, &offset); fs->inode_table[i]->inode_ref = (block << 16) | offset; diff --git a/mkfs/dirscan.c b/mkfs/dirscan.c index 06f4d79..c0572f5 100644 --- a/mkfs/dirscan.c +++ b/mkfs/dirscan.c @@ -211,7 +211,7 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, dev_t devstart, if (ret) { sqfs_perror(n->name, "completing xattr key-value pairs", ret); - return -1; + goto fail; } free(extra); |