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

Commit b420b583 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

libui: improve Region::validate

This protects libui against a buggy/malicious client who sends a
Region with zero rectangle.

Bug: 72976082
Test: boots
Change-Id: Ifa0f85adc226bf7215386bdd9e0a27edacda58dc
parent 989fc50a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -513,6 +513,12 @@ void Region::rasterizer::flushSpan()

bool Region::validate(const Region& reg, const char* name, bool silent)
{
    if (reg.mStorage.isEmpty()) {
        ALOGE_IF(!silent, "%s: mStorage is empty, which is never valid", name);
        // return immediately as the code below assumes mStorage is non-empty
        return false;
    }

    bool result = true;
    const_iterator cur = reg.begin();
    const_iterator const tail = reg.end();