return NULL;
memset(buffer, 0, sizeof(struct ext2_qcow2_hdr));
- if (ext2fs_llseek(fd, 0, SEEK_SET < 0))
+ if (ext2fs_llseek(fd, 0, SEEK_SET < 0)) {
+ ext2fs_free_mem(&buffer);
return NULL;
+ }
size = read(fd, buffer, sizeof(struct ext2_qcow2_hdr));
if (size != sizeof(struct ext2_qcow2_hdr)) {
if (ret)
return ret;
- if (ext2fs_llseek(fd, img->l1_offset, SEEK_SET) < 0)
+ if (ext2fs_llseek(fd, img->l1_offset, SEEK_SET) < 0) {
+ ext2fs_free_mem(&table);
return errno;
+ }
size = read(fd, table, l1_size);
if (size != l1_size) {
errcode_t ret = 0;
unsigned int l1_index, l2_index;
ext2_off64_t offset;
- blk64_t *l1_table, *l2_table;
+ blk64_t *l1_table, *l2_table = NULL;
void *copy_buf = NULL;
size_t size;
}
/* Resize the output image to the filesystem size */
- if (ext2fs_llseek(raw_fd, img.image_size - 1, SEEK_SET) < 0)
- return errno;
+ if (ext2fs_llseek(raw_fd, img.image_size - 1, SEEK_SET) < 0) {
+ ret = errno;
+ goto out;
+ }
((char *)copy_buf)[0] = 0;
size = write(raw_fd, copy_buf, 1);
- if (size != 1)
- return errno;
+ if (size != 1) {
+ ret = errno;
+ goto out;
+ }
out:
if (copy_buf)