return ret;
}
-static void add_clone_source(struct btrfs_send *s, u64 root_id)
+static int add_clone_source(struct btrfs_send *s, u64 root_id)
{
s->clone_sources = realloc(s->clone_sources,
sizeof(*s->clone_sources) * (s->clone_sources_count + 1));
+
+ if (!s->clone_sources)
+ return -ENOMEM;
s->clone_sources[s->clone_sources_count++] = root_id;
+
+ return 0;
}
static int write_buf(int fd, const void *buf, int size)
goto out;
}
- add_clone_source(&send, root_id);
+ ret = add_clone_source(&send, root_id);
+ if (ret < 0) {
+ fprintf(stderr, "ERROR: not enough memory\n");
+ goto out;
+ }
subvol_uuid_search_finit(&send.sus);
free(subvol);
subvol = NULL;
goto out;
}
- add_clone_source(&send, parent_root_id);
+ ret = add_clone_source(&send, parent_root_id);
+ if (ret < 0) {
+ fprintf(stderr, "ERROR: not enough memory\n");
+ goto out;
+ }
}
for (i = optind; i < argc; i++) {
goto out;
/* done with this subvol, so add it to the clone sources */
- add_clone_source(&send, root_id);
+ ret = add_clone_source(&send, root_id);
+ if (ret < 0) {
+ fprintf(stderr, "ERROR: not enough memory\n");
+ goto out;
+ }
parent_root_id = 0;
full_send = 0;