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_utils.h b/libhwcomposer/hwc_utils.h
index 729a649..54a118c 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -33,7 +33,7 @@
#define ALIGN_TO(x, align) (((x) + ((align)-1)) & ~((align)-1))
#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-#define MAX_NUM_LAYERS 32 //includes fb layer
+#define MAX_NUM_APP_LAYERS 32
// For support of virtual displays
#define HWC_DISPLAY_VIRTUAL (HWC_DISPLAY_EXTERNAL+1)
@@ -90,7 +90,7 @@
int fbLayerIndex; //Always last for now. = numAppLayers
//Video specific
int yuvCount;
- int yuvIndices[MAX_NUM_LAYERS];
+ int yuvIndices[MAX_NUM_APP_LAYERS];
int extOnlyLayerIndex;
bool needsAlphaScale;
bool preMultipliedAlpha;