Camera: Fix possible invalid metadata access
Camera metadata entries can become invalid
after updates. Avoid using the possibly
released entry pointer when extending
camera characteristics with dynamic depth
tags.
Additionally simplify rotate and crop
region checks.
Bug: 152240541
Test: cameraservice_test
Change-Id: I416739ed7e128f4ec94353ec2938b9bf226be182
diff --git a/services/camera/libcameraservice/tests/RotateAndCropMapperTest.cpp b/services/camera/libcameraservice/tests/RotateAndCropMapperTest.cpp
index c638d40..3c187cd 100644
--- a/services/camera/libcameraservice/tests/RotateAndCropMapperTest.cpp
+++ b/services/camera/libcameraservice/tests/RotateAndCropMapperTest.cpp
@@ -38,10 +38,9 @@
#define EXPECT_EQUAL_WITHIN_N(vec, array, N, msg) \
{ \
- std::vector<int32_t> vec_diff; \
- std::transform(vec.begin(), vec.end(), array, \
- std::back_inserter(vec_diff), std::minus()); \
- EXPECT_THAT(vec_diff, Each(AllOf(Ge(-N), Le(N)))) << msg; \
+ for (size_t i = 0; i < vec.size(); i++) { \
+ EXPECT_THAT(vec[i] - array[i], AllOf(Ge(-N), Le(N))) << msg " failed at index:" << i; \
+ } \
}
int32_t testActiveArray[] = {100, 100, 4000, 3000};