Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8fc623eb authored by David Anderson's avatar David Anderson
Browse files

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
parent 22387708
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -312,6 +312,11 @@ static inline bool HasFillValue(uint32_t* buffer, size_t count) {


bool ImageBuilder::AddPartitionImage(const LpMetadataPartition& partition,
bool ImageBuilder::AddPartitionImage(const LpMetadataPartition& partition,
                                     const std::string& file) {
                                     const std::string& file) {
    if (partition.num_extents == 0) {
        LERROR << "Partition size is zero: " << GetPartitionName(partition);
        return false;
    }

    // Track which extent we're processing.
    // Track which extent we're processing.
    uint32_t extent_index = partition.first_extent_index;
    uint32_t extent_index = partition.first_extent_index;