diff options
author | Ramakant Singh <ramaka@codeaurora.org> | 2015-02-25 16:19:43 +0530 |
---|---|---|
committer | Ramakant Singh <ramaka@codeaurora.org> | 2015-02-25 17:35:42 +0530 |
commit | cab868bf6d94bcc2d9b2facdd51a12dfdd3a14e6 (patch) | |
tree | 583435f0f36495ae9317822e4b721319aba0003d /libcopybit | |
parent | 92fff342470ca0196f4485f78c01ad8941eca336 (diff) | |
download | display-cab868bf6d94bcc2d9b2facdd51a12dfdd3a14e6.tar.gz |
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
Diffstat (limited to 'libcopybit')
-rw-r--r-- | libcopybit/copybit.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libcopybit/copybit.cpp b/libcopybit/copybit.cpp index e4624e0b..9783896d 100644 --- a/libcopybit/copybit.cpp +++ b/libcopybit/copybit.cpp @@ -512,7 +512,11 @@ static int stretch_copybit( // Set Color Space for MDP to configure CSC matrix 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)) { 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; ctx = (copybit_context_t *)malloc(sizeof(copybit_context_t)); + + if (ctx == NULL ) { + return COPYBIT_FAILURE; + } + memset(ctx, 0, sizeof(*ctx)); ctx->device.common.tag = HARDWARE_DEVICE_TAG; |