libhwcomposer: Add null checks

SurfaceFlinger calls a hwc_set with a NULL context and
list when it is releasing the HWC. Check the validity
of the pointers before using it.

Change-Id: I5b61cc50a85b9b660646789b2cf9a0f4ee6e4a5c
This commit is contained in:
Naomi Luis 2011-03-07 17:42:00 -08:00 committed by Govind Surti
parent 7e5f14bb48
commit f59c70eab4

View File

@ -122,8 +122,8 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) {
hwc_context_t* ctx = (hwc_context_t*)(dev);
if(!ctx) {
LOGE("hwc_prepare null context ");
if(!ctx || !list) {
LOGE("hwc_prepare invalid context or list");
return -1;
}
@ -242,8 +242,8 @@ static int hwc_set(hwc_composer_device_t *dev,
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
if(!ctx) {
LOGE("hwc_set null context ");
if(!ctx || !list) {
LOGE("hwc_set invalid context or list");
return -1;
}
@ -272,6 +272,11 @@ static int hwc_set(hwc_composer_device_t *dev,
static int hwc_device_close(struct hw_device_t *dev)
{
if(!dev) {
LOGE("hwc_device_close null device pointer");
return -1;
}
struct hwc_context_t* ctx = (struct hwc_context_t*)dev;
private_hwc_module_t* hwcModule = reinterpret_cast<private_hwc_module_t*>(