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
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index b53c563..36da084 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -513,6 +513,12 @@
 
 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();