Camera: Do not forward capture_result in error condition
If HAL calls process_capture_result with invalid buffers, the HIDL
wrapper shouldn't forward it to camera service, since the CaptureResult
structure may not be completely initialized.
Test: Run GoogleCamera
Bug: 74433802
Change-Id: Iaf20b542af5b11ffbedf709e99137b69d77a9ad3
diff --git a/camera/device/3.4/default/CameraDeviceSession.cpp b/camera/device/3.4/default/CameraDeviceSession.cpp
index b032357..ad7f6f5 100644
--- a/camera/device/3.4/default/CameraDeviceSession.cpp
+++ b/camera/device/3.4/default/CameraDeviceSession.cpp
@@ -450,8 +450,12 @@
CameraDeviceSession *d =
const_cast<CameraDeviceSession*>(static_cast<const CameraDeviceSession*>(cb));
- CaptureResult result;
- d->constructCaptureResult(result.v3_2, hal_result);
+ CaptureResult result = {};
+ status_t ret = d->constructCaptureResult(result.v3_2, hal_result);
+ if (ret != OK) {
+ return;
+ }
+
result.physicalCameraMetadata.resize(hal_result->num_physcam_metadata);
for (uint32_t i = 0; i < hal_result->num_physcam_metadata; i++) {
std::string physicalId = hal_result->physcam_ids[i];