Fix division by zero in I420Buffer::CropAndScaleFrom

Bug: webrtc:11741
Change-Id: I5ad495084573e55adb77696e6f61880c1378d0c8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178440
Commit-Queue: Dan Minor <dminor@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31799}
diff --git a/api/video/i420_buffer.cc b/api/video/i420_buffer.cc
index 62fa183..2a52217 100644
--- a/api/video/i420_buffer.cc
+++ b/api/video/i420_buffer.cc
@@ -215,9 +215,11 @@
 
 void I420Buffer::CropAndScaleFrom(const I420BufferInterface& src) {
   const int crop_width =
-      std::min(src.width(), width() * src.height() / height());
+      height() > 0 ? std::min(src.width(), width() * src.height() / height())
+                   : src.width();
   const int crop_height =
-      std::min(src.height(), height() * src.width() / width());
+      width() > 0 ? std::min(src.height(), height() * src.width() / width())
+                  : src.height();
 
   CropAndScaleFrom(src, (src.width() - crop_width) / 2,
                    (src.height() - crop_height) / 2, crop_width, crop_height);