summaryrefslogtreecommitdiff
path: root/lib/sqfs/xattr_reader.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-02 15:41:28 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-02 15:41:28 +0200
commit0a40372096c624e5fceebe9cb90305946505dd68 (patch)
treeae18c0376d87304fadc23b43596fe4574f4b9125 /lib/sqfs/xattr_reader.c
parent16b5b997d78e3d37a93701f9f32f91ae33ebb8fe (diff)
cleanup: merge error paths in xattr reader restore_kv_pairs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/xattr_reader.c')
-rw-r--r--lib/sqfs/xattr_reader.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/sqfs/xattr_reader.c b/lib/sqfs/xattr_reader.c
index 42a7e51..8859db8 100644
--- a/lib/sqfs/xattr_reader.c
+++ b/lib/sqfs/xattr_reader.c
@@ -237,36 +237,28 @@ static int restore_kv_pairs(xattr_reader_t *xr, fstree_t *fs,
return -1;
val = read_value(xr, key);
- if (val == NULL) {
- free(key);
- return -1;
- }
+ if (val == NULL)
+ goto fail_key;
ret = str_table_get_index(&fs->xattr_keys,
(const char *)key->key, &key_idx);
- if (ret) {
- free(val);
- free(key);
- return -1;
- }
+ if (ret)
+ goto fail_kv;
ret = str_table_get_index(&fs->xattr_values,
(const char *)val->value, &val_idx);
- if (ret) {
- free(val);
- free(key);
- return -1;
- }
+ if (ret)
+ goto fail_kv;
if (sizeof(size_t) > sizeof(uint32_t)) {
if (key_idx > 0xFFFFFFFFUL) {
fputs("too many unique xattr keys\n", stderr);
- return -1;
+ goto fail_kv;
}
if (val_idx > 0xFFFFFFFFUL) {
fputs("too many unique xattr values\n", stderr);
- return -1;
+ goto fail_kv;
}
}
@@ -278,6 +270,11 @@ static int restore_kv_pairs(xattr_reader_t *xr, fstree_t *fs,
}
return 0;
+fail_kv:
+ free(val);
+fail_key:
+ free(key);
+ return -1;
}
int xattr_reader_restore_node(xattr_reader_t *xr, fstree_t *fs,