core/dbus-execute: fix memleak on Mount/ExtensionImages parse failure

Define mount_image_free_many() in our usual fashion for use in
CLEANUP_ARRAY and ensure proper cleanup on error paths.
This commit is contained in:
Mike Yuan
2026-01-19 23:22:32 +01:00
parent 331fef07d8
commit 00f459f30f
5 changed files with 56 additions and 35 deletions
+6 -9
View File
@@ -3098,19 +3098,16 @@ int bind_mount_add(BindMount **b, size_t *n, const BindMount *item) {
return 0;
}
MountImage* mount_image_free_many(MountImage *m, size_t *n) {
assert(n);
assert(m || *n == 0);
void mount_image_free_many(MountImage *m, size_t n) {
assert(m || n == 0);
for (size_t i = 0; i < *n; i++) {
free(m[i].source);
free(m[i].destination);
mount_options_free_all(m[i].mount_options);
FOREACH_ARRAY(i, m, n) {
free(i->source);
free(i->destination);
mount_options_free_all(i->mount_options);
}
free(m);
*n = 0;
return NULL;
}
int mount_image_add(MountImage **m, size_t *n, const MountImage *item) {