SkAnimatedImage: Reject invalid crops

A crop is invalid if it is empty/unsorted or does not intersect with
the image. Android (the only known client of the cropping API) will not
pass such a rectangle to the API, but this prevents other clients from
passing an invalid rectangle.

Change-Id: I09e007ecd378c358a1c604aff518035090f1e0a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333224
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
diff --git a/src/android/SkAnimatedImage.cpp b/src/android/SkAnimatedImage.cpp
index 9c57c6c..5c35db8 100644
--- a/src/android/SkAnimatedImage.cpp
+++ b/src/android/SkAnimatedImage.cpp
@@ -25,6 +25,10 @@
         return nullptr;
     }
 
+    if (!requestedInfo.bounds().contains(cropRect)) {
+        return nullptr;
+    }
+
     auto scaledSize = requestedInfo.dimensions();
     auto decodeInfo = requestedInfo;
     if (codec->getEncodedFormat() != SkEncodedImageFormat::kWEBP