HWC copybit: Add conditional check for src/dst crop w and h
It's better to check the source/dst crop width and height
for null and -ve value, may cause float exception.
CRs-Fixed: 596099
Change-Id: I34881cf37a99fb52be6429e27deba4ac12ed2474
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index 47b9225..38d8d5d 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -188,8 +188,15 @@
dst_h = layer->displayFrame.bottom - layer->displayFrame.top;
dst_w = layer->displayFrame.right - layer->displayFrame.left;
+ if(src_w <=0 || src_h<=0 ||dst_w<=0 || dst_h<=0 ) {
+ ALOGE("%s: wrong params for display screen_w=%d \
+ src_crop_width=%d screen_h=%d src_crop_height=%d",
+ __FUNCTION__, dst_w,src_w,dst_h,src_h);
+ return false;
+ }
dx = (float)dst_w/src_w;
dy = (float)dst_h/src_h;
+
if (dx > MAX_SCALE_FACTOR || dx < MIN_SCALE_FACTOR)
return false;
@@ -448,8 +455,8 @@
if(screen_w <=0 || screen_h<=0 ||src_crop_width<=0 || src_crop_height<=0 ) {
ALOGE("%s: wrong params for display screen_w=%d src_crop_width=%d \
- screen_w=%d src_crop_width=%d", __FUNCTION__, screen_w,
- src_crop_width,screen_w,src_crop_width);
+ screen_h=%d src_crop_height=%d", __FUNCTION__, screen_w,
+ src_crop_width,screen_h,src_crop_height);
return -1;
}