From f59c70eab45f43df0d0a7e97489dd1e6607fc4f0 Mon Sep 17 00:00:00 2001 From: Naomi Luis Date: Mon, 7 Mar 2011 17:42:00 -0800 Subject: [PATCH] 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 --- libhwcomposer/hwcomposer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libhwcomposer/hwcomposer.cpp b/libhwcomposer/hwcomposer.cpp index b741593..2da07ff 100755 --- a/libhwcomposer/hwcomposer.cpp +++ b/libhwcomposer/hwcomposer.cpp @@ -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(