hwc: Add null check for copybit context and source handler
Add malloc return null check for copybit context 'ctx', and source handler null check before getting metadata. Change-Id: I9466de72d2b47ec2ba58fd50e66022555652f4c8
This commit is contained in:
@@ -512,7 +512,11 @@ static int stretch_copybit(
|
|||||||
|
|
||||||
// Set Color Space for MDP to configure CSC matrix
|
// Set Color Space for MDP to configure CSC matrix
|
||||||
req->color_space = ITU_R_601;
|
req->color_space = ITU_R_601;
|
||||||
MetaData_t *metadata = (MetaData_t *)src_hnd->base_metadata;
|
MetaData_t *metadata = NULL;
|
||||||
|
|
||||||
|
if (src_hnd != NULL)
|
||||||
|
metadata = (MetaData_t *)src_hnd->base_metadata;
|
||||||
|
|
||||||
if (metadata && (metadata->operation & UPDATE_COLOR_SPACE)) {
|
if (metadata && (metadata->operation & UPDATE_COLOR_SPACE)) {
|
||||||
req->color_space = metadata->colorSpace;
|
req->color_space = metadata->colorSpace;
|
||||||
}
|
}
|
||||||
@@ -722,6 +726,11 @@ static int open_copybit(const struct hw_module_t* module, const char* name,
|
|||||||
}
|
}
|
||||||
copybit_context_t *ctx;
|
copybit_context_t *ctx;
|
||||||
ctx = (copybit_context_t *)malloc(sizeof(copybit_context_t));
|
ctx = (copybit_context_t *)malloc(sizeof(copybit_context_t));
|
||||||
|
|
||||||
|
if (ctx == NULL ) {
|
||||||
|
return COPYBIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
|
|
||||||
ctx->device.common.tag = HARDWARE_DEVICE_TAG;
|
ctx->device.common.tag = HARDWARE_DEVICE_TAG;
|
||||||
|
|||||||
Reference in New Issue
Block a user