Skip to content

Commit

Permalink
writer: Set errno
Browse files Browse the repository at this point in the history
Set errno in the same way as it's done further down in the same file
https://github.com/containers/composefs/blob/d5ffbeb6844cdbe029f9c10cfa98239e2d6b1570/libcomposefs/lcfs-writer.c#L1472

Set errno after munmap() to avoid overwriting the original errno.

Signed-off-by: Erik Sjölund <[email protected]>
  • Loading branch information
eriksjolund committed Mar 20, 2024
1 parent 9bc76dd commit 9b417be
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libcomposefs/lcfs-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,8 @@ int lcfs_version_from_fd(int fd)
}
if (lcfs_u32_from_file(header->magic) != LCFS_EROFS_MAGIC ||
lcfs_u32_from_file(header->version) != LCFS_EROFS_VERSION) {
errno = EINVAL;
munmap(header, header_size);
errno = EINVAL;
return -1;
}

Expand Down Expand Up @@ -1155,6 +1155,7 @@ struct lcfs_node_s *lcfs_node_clone(struct lcfs_node_s *node)
if (key == NULL || value == NULL) {
free(key);
free(value);
errno = ENOMEM;
return NULL;
}
new->xattrs[i].key = key;
Expand Down

0 comments on commit 9b417be

Please sign in to comment.