liblp: Fix a crash when adding an image to a partition with no extents.

Bug: N/A
Test: lpmake --partition=system:readonly:0 --image=system=system.img
Change-Id: I4de616cc1b9ca2838d38518ec24a382f4bc1b1be
This commit is contained in:
David Anderson 2023-02-08 21:44:40 -08:00
parent 22387708fc
commit 8fc623eb63

View file

@ -312,6 +312,11 @@ static inline bool HasFillValue(uint32_t* buffer, size_t count) {
bool ImageBuilder::AddPartitionImage(const LpMetadataPartition& partition,
const std::string& file) {
if (partition.num_extents == 0) {
LERROR << "Partition size is zero: " << GetPartitionName(partition);
return false;
}
// Track which extent we're processing.
uint32_t extent_index = partition.first_extent_index;