From 5cbf74bc0c94a50da2d981e72216593ed7bba41c Mon Sep 17 00:00:00 2001 From: Sejun Park Date: Thu, 22 Mar 2018 12:47:20 +0900 Subject: [PATCH] fixed svace issues Change-Id: I6d836dc0a0ec8e58645144b4f41ff2d4e45608fb --- exynos4/libcodec/video/v4l2/dec/ExynosVideoDecoder.c | 16 ++++++---------- exynos4/libcodec/video/v4l2/enc/ExynosVideoEncoder.c | 16 ++++++---------- openmax/component/video/enc/h264/Exynos_OMX_H264enc.c | 5 +++++ openmax/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c | 5 +++++ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/exynos4/libcodec/video/v4l2/dec/ExynosVideoDecoder.c b/exynos4/libcodec/video/v4l2/dec/ExynosVideoDecoder.c index 24be448..8adb7be 100755 --- a/exynos4/libcodec/video/v4l2/dec/ExynosVideoDecoder.c +++ b/exynos4/libcodec/video/v4l2/dec/ExynosVideoDecoder.c @@ -151,27 +151,23 @@ static void *MFC_Decoder_Init(int nMemoryType) pCtx->nMemoryType = nMemoryType; - pMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); - if (pMutex == NULL) { + pCtx->pInMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); + if (pCtx->pInMutex == NULL) { ALOGE("%s: Failed to allocate mutex about input buffer", __func__); goto EXIT_QUERYCAP_FAIL; } - if (pthread_mutex_init(pMutex, NULL) != 0) { - free(pMutex); + if (pthread_mutex_init(pCtx->pInMutex, NULL) != 0) { goto EXIT_QUERYCAP_FAIL; } - pCtx->pInMutex = (void*)pMutex; - pMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); - if (pMutex == NULL) { + pCtx->pOutMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); + if (pCtx->pOutMutex == NULL) { ALOGE("%s: Failed to allocate mutex about output buffer", __func__); goto EXIT_QUERYCAP_FAIL; } - if (pthread_mutex_init(pMutex, NULL) != 0) { - free(pMutex); + if (pthread_mutex_init(pCtx->pOutMutex, NULL) != 0) { goto EXIT_QUERYCAP_FAIL; } - pCtx->pOutMutex = (void*)pMutex; return (void *)pCtx; diff --git a/exynos4/libcodec/video/v4l2/enc/ExynosVideoEncoder.c b/exynos4/libcodec/video/v4l2/enc/ExynosVideoEncoder.c index 2851560..0469587 100755 --- a/exynos4/libcodec/video/v4l2/enc/ExynosVideoEncoder.c +++ b/exynos4/libcodec/video/v4l2/enc/ExynosVideoEncoder.c @@ -161,27 +161,23 @@ static void *MFC_Encoder_Init(int nMemoryType) pCtx->nMemoryType = nMemoryType; - pMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); - if (pMutex == NULL) { + pCtx->pInMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); + if (pCtx->pInMutex == NULL) { ALOGE("%s: Failed to allocate mutex about input buffer", __func__); goto EXIT_QUERYCAP_FAIL; } - if (pthread_mutex_init(pMutex, NULL) != 0) { - free(pMutex); + if (pthread_mutex_init(pCtx->pInMutex, NULL) != 0) { goto EXIT_QUERYCAP_FAIL; } - pCtx->pInMutex = (void*)pMutex; - pMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); - if (pMutex == NULL) { + pCtx->pOutMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); + if (pCtx->pOutMutex == NULL) { ALOGE("%s: Failed to allocate mutex about output buffer", __func__); goto EXIT_QUERYCAP_FAIL; } - if (pthread_mutex_init(pMutex, NULL) != 0) { - free(pMutex); + if (pthread_mutex_init(pCtx->pOutMutex, NULL) != 0) { goto EXIT_QUERYCAP_FAIL; } - pCtx->pOutMutex = (void*)pMutex; return (void *)pCtx; diff --git a/openmax/component/video/enc/h264/Exynos_OMX_H264enc.c b/openmax/component/video/enc/h264/Exynos_OMX_H264enc.c index e3eb799..41cd3f2 100755 --- a/openmax/component/video/enc/h264/Exynos_OMX_H264enc.c +++ b/openmax/component/video/enc/h264/Exynos_OMX_H264enc.c @@ -1023,6 +1023,11 @@ OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) pVideoEnc->pMFCEncOutputBuffer[i] = (CODEC_ENC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_ENC_BUFFER)); + if (!pVideoEnc->pMFCEncOutputBuffer[i]) { + ret = OMX_ErrorInsufficientResources; + goto ALLOC_FAILED; + } + if (pOutbufOps->Get_Buffer) { if (pOutbufOps->Get_Buffer(pH264Enc->hMFCH264Handle.hMFCHandle, i, &pBuffer) != VIDEO_ERROR_NONE) { Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get Output buffer info"); diff --git a/openmax/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c b/openmax/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c index d775ad4..1ecfe21 100755 --- a/openmax/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c +++ b/openmax/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c @@ -1157,6 +1157,11 @@ OMX_ERRORTYPE Mpeg4CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) pVideoEnc->pMFCEncOutputBuffer[i] = (CODEC_ENC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_ENC_BUFFER)); + if (!pVideoEnc->pMFCEncOutputBuffer[i]) { + ret = OMX_ErrorInsufficientResources; + goto ALLOC_FAILED; + } + if (pOutbufOps->Get_Buffer) { if (pOutbufOps->Get_Buffer(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, i, &pBuffer) != VIDEO_ERROR_NONE) { Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get Output buffer info"); -- 2.7.4