core: resolved prevent defect
authorTaehwan Kim <t_h.kim@samsung.com>
Wed, 13 Feb 2013 10:21:33 +0000 (10:21 +0000)
committerTaehwan Kim <t_h.kim@samsung.com>
Wed, 20 Feb 2013 01:18:15 +0000 (01:18 +0000)
- 17726 : Null pointer dereferences

Change-Id: Id836e6fe16c4520941a03163b32516658d5e6947
Signed-off-by: Taehwan Kim <t_h.kim@samsung.com>
core/Exynos_OMX_Core.c

index 4e12c13ab2c428b37d818e920ff1fa0d8f56aa43..4fb3c4a365222a0ac6b7732ada9c98079221e4bf 100644 (file)
@@ -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;