diff --git a/api/video/i420_buffer.cc b/api/video/i420_buffer.cc index 62fa1837ed..2a52217ce3 100644 --- a/api/video/i420_buffer.cc +++ b/api/video/i420_buffer.cc @@ -215,9 +215,11 @@ void I420Buffer::CropAndScaleFrom(const I420BufferInterface& src, 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);