hwc: Fix to avoid heap corruption
- Check for MAX_NUM_APP_LAYERS before updating yuv indices array.
- Fall back to GPU composition when number of app layers exceeds
MAX_NUM_APP_LAYERS to avoid heap corruption.
Change-Id: Ieb91b705a0a5f50ce2f8829d1f1ee048d44b7d2e
diff --git a/libhwcomposer/hwc_mdpcomp.h b/libhwcomposer/hwc_mdpcomp.h
index a0255b7..e2800d2 100644
--- a/libhwcomposer/hwc_mdpcomp.h
+++ b/libhwcomposer/hwc_mdpcomp.h
@@ -78,7 +78,7 @@
struct FrameInfo {
/* maps layer list to mdp list */
int layerCount;
- int layerToMDP[MAX_NUM_LAYERS];
+ int layerToMDP[MAX_NUM_APP_LAYERS];
/* maps mdp list to layer list */
int mdpCount;
@@ -86,7 +86,7 @@
/* layer composing on FB? */
int fbCount;
- bool isFBComposed[MAX_NUM_LAYERS];
+ bool isFBComposed[MAX_NUM_APP_LAYERS];
bool needsRedraw;
int fbZ;
@@ -104,7 +104,7 @@
int mdpCount;
int cacheCount;
int fbZ;
- buffer_handle_t hnd[MAX_NUM_LAYERS];
+ buffer_handle_t hnd[MAX_NUM_APP_LAYERS];
/* c'tor */
LayerCache();