[libcamera-devel] [PATCH v2] android: camera_device: Add null check for ScalerCrop control
Phi-Bang Nguyen
pnguyen at baylibre.com
Fri Mar 26 23:04:10 CET 2021
The ScalerCrop control does not contain the null check which can
cause the camera HAL crash at boot. Fix it.
Signed-off-by: Phi-Bang Nguyen <pnguyen at baylibre.com>
---
src/android/camera_device.cpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ae693664..a8108e3a 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1107,11 +1107,14 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
* use the maximum and minimum crop rectangles to calculate the
* digital zoom factor.
*/
+ float maxZoom = { 1 };
const auto info = controlsInfo.find(&controls::ScalerCrop);
- Rectangle min = info->second.min().get<Rectangle>();
- Rectangle max = info->second.max().get<Rectangle>();
- float maxZoom = std::min(1.0f * max.width / min.width,
- 1.0f * max.height / min.height);
+ if (info != controlsInfo.end()) {
+ Rectangle min = info->second.min().get<Rectangle>();
+ Rectangle max = info->second.max().get<Rectangle>();
+ maxZoom = std::min(1.0f * max.width / min.width,
+ 1.0f * max.height / min.height);
+ }
staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
&maxZoom, 1);
}
--
2.25.1
More information about the libcamera-devel
mailing list