Fix unlikely occurences of json_object leaks on error path.

In most cases it relates to error path triggering on general OOM.
This commit is contained in:
Ondrej Kozina
2023-01-23 15:04:24 +01:00
parent cb177c5076
commit 9a96e260aa
5 changed files with 35 additions and 7 deletions

View File

@@ -358,7 +358,10 @@ int LUKS2_generate_hdr(
json_object_object_add(jobj_segment, "integrity", jobj_integrity);
}
json_object_object_add_by_uint(jobj_segments, 0, jobj_segment);
if (json_object_object_add_by_uint(jobj_segments, 0, jobj_segment)) {
json_object_put(jobj_segment);
goto err;
}
json_object_object_add(jobj_config, "json_size", crypt_jobj_new_uint64(metadata_size - LUKS2_HDR_BIN_LEN));
json_object_object_add(jobj_config, "keyslots_size", crypt_jobj_new_uint64(keyslots_size));