fix build
inode_allocate_file_extents should return NULL if allocation fails.
Bug: 16984795
Change-Id: I7d2b9d61ca81f8e1869dbac3d8bde79bb5799fa9
diff --git a/ext4_utils/contents.c b/ext4_utils/contents.c
index fb3a38d..3144de9 100644
--- a/ext4_utils/contents.c
+++ b/ext4_utils/contents.c
@@ -194,10 +194,11 @@
if (len > 0) {
struct block_allocation* alloc = inode_allocate_file_extents(inode, len, filename);
-
- alloc->filename = strdup(filename);
- alloc->next = saved_allocation_head;
- saved_allocation_head = alloc;
+ if (alloc) {
+ alloc->filename = strdup(filename);
+ alloc->next = saved_allocation_head;
+ saved_allocation_head = alloc;
+ }
}
inode->i_mode = S_IFREG;
diff --git a/ext4_utils/extent.c b/ext4_utils/extent.c
index 7142c8b..1900b10 100644
--- a/ext4_utils/extent.c
+++ b/ext4_utils/extent.c
@@ -210,11 +210,11 @@
alloc = do_inode_allocate_extents(inode, len);
if (alloc == NULL) {
error("failed to allocate extents for %"PRIu64" bytes", len);
- return;
+ return NULL;
}
extent_create_backing_file(alloc, len, filename);
- return alloc;
+ return alloc;
}
/* Allocates enough blocks to hold len bytes and connects them to an inode */