summaryrefslogtreecommitdiff
path: root/libhwc2.1/pixel-display.cpp
diff options
context:
space:
mode:
authorMidas Chien <midaschieh@google.com>2022-06-17 17:28:57 +0800
committerMidas Chien <midaschieh@google.com>2022-06-19 12:54:46 +0800
commit56e448682446c1f12fea75a77c40bcf2497947c7 (patch)
treeff7671cac96a5c7ff1d2834bb3638a61a3b884fa /libhwc2.1/pixel-display.cpp
parent7ae595591d74ef2bcb5240f3dafa570a0de32a1f (diff)
libhwc2.1: fix incorrect operator to clear histogrambuffer
Use std:fill() to reset and clear() to remove all elements. Bug: 235782215 Test: enroll face Change-Id: If16589e95a18ee4f496379512e5ff9f0de704471
Diffstat (limited to 'libhwc2.1/pixel-display.cpp')
-rw-r--r--libhwc2.1/pixel-display.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libhwc2.1/pixel-display.cpp b/libhwc2.1/pixel-display.cpp
index e575ad1..81f5f94 100644
--- a/libhwc2.1/pixel-display.cpp
+++ b/libhwc2.1/pixel-display.cpp
@@ -191,6 +191,11 @@ ndk::ScopedAStatus Display::histogramSample(const RoiRect &roi, const Weight &we
ALOGI("mDevice is NULL \n");
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
+ if (histogrambuffer == nullptr) {
+ ALOGE("histogrambuffer is null");
+ *_aidl_return = HistogramErrorCode::BAD_HIST_DATA;
+ return ndk::ScopedAStatus::ok();
+ }
if (mMediator.isDisplayPowerOff() == true) {
*_aidl_return = HistogramErrorCode::DISPLAY_POWEROFF; // panel is off
return ndk::ScopedAStatus::ok();
@@ -225,7 +230,9 @@ ndk::ScopedAStatus Display::histogramSample(const RoiRect &roi, const Weight &we
RoiRect roiCaled = mMediator.calRoi(roi); // fit roi coordinates to RRS
runMediator(roiCaled, weight, pos, histogrambuffer);
if (mMediator.isSecureContentPresenting() == true) {
- memset(histogrambuffer, 0, histogram::HISTOGRAM_BINS_SIZE * sizeof(histogrambuffer[0]));
+ /* clear data to avoid leakage */
+ std::fill(histogrambuffer->begin(), histogrambuffer->end(), 0);
+ histogrambuffer->clear();
*_aidl_return = HistogramErrorCode::DRM_PLAYING; // panel is playing DRM content
return ndk::ScopedAStatus::ok();
}