From: Taehwan Kim Date: Wed, 13 Feb 2013 10:21:33 +0000 (+0000) Subject: core: resolved prevent defect X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3a3fb868670e64d949bf93a8e5de5cdbbd3cf41e;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_openmax.git core: resolved prevent defect - 17726 : Null pointer dereferences Change-Id: Id836e6fe16c4520941a03163b32516658d5e6947 Signed-off-by: Taehwan Kim --- diff --git a/core/Exynos_OMX_Core.c b/core/Exynos_OMX_Core.c index 4e12c13..4fb3c4a 100644 --- a/core/Exynos_OMX_Core.c +++ b/core/Exynos_OMX_Core.c @@ -210,12 +210,13 @@ EXIT: OMX_API OMX_ERRORTYPE OMX_APIENTRY Exynos_OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent) { OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_COMPONENT *currentComponent; - EXYNOS_OMX_COMPONENT *deleteComponent; + EXYNOS_OMX_COMPONENT *currentComponent = NULL; + EXYNOS_OMX_COMPONENT *deleteComponent = NULL; FunctionIn(); - if (gInitialized != 1) { + if ((gInitialized != 1) || + (gLoadComponentList == NULL)) { ret = OMX_ErrorNotReady; goto EXIT; } @@ -226,18 +227,23 @@ OMX_API OMX_ERRORTYPE OMX_APIENTRY Exynos_OMX_FreeHandle(OMX_IN OMX_HANDLETYPE h } Exynos_OSAL_MutexLock(ghLoadComponentListMutex); - currentComponent = gLoadComponentList; if (gLoadComponentList->pOMXComponent == hComponent) { deleteComponent = gLoadComponentList; gLoadComponentList = gLoadComponentList->nextOMXComp; } else { - while ((currentComponent != NULL) && (((EXYNOS_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent != hComponent)) + currentComponent = gLoadComponentList; + + while ((currentComponent != NULL) && + (currentComponent->nextOMXComp != NULL)) { + if (currentComponent->nextOMXComp->pOMXComponent == hComponent) { + deleteComponent = currentComponent->nextOMXComp; + currentComponent->nextOMXComp = deleteComponent->nextOMXComp; + break; + } currentComponent = currentComponent->nextOMXComp; + } - if (((EXYNOS_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent == hComponent) { - deleteComponent = currentComponent->nextOMXComp; - currentComponent->nextOMXComp = deleteComponent->nextOMXComp; - } else if (currentComponent == NULL) { + if (deleteComponent == NULL) { ret = OMX_ErrorComponentNotFound; Exynos_OSAL_MutexUnlock(ghLoadComponentListMutex); goto EXIT;