Fix defects detected by static analysis tool
[platform/core/uifw/multi-assistant-service.git] / src / service_plugin.cpp
index f12323e..eb02cf4 100644 (file)
@@ -501,9 +501,15 @@ int CServicePlugin::initialize(void)
        snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME);
 
        char *error;
-       mPluginHandle = NULL;
+       mPluginHandle = nullptr;
        mPluginHandle = dlopen(filepath, RTLD_LAZY);
-       if (NULL != (error = dlerror())) {
+       if (nullptr != (error = dlerror())) {
+               MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
+               if (mPluginHandle) dlclose(mPluginHandle);
+               mPluginHandle = nullptr;
+               return -1; //MAS_ERROR_OPERATION_FAILED;
+       }
+       if (nullptr == mPluginHandle) {
                MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error);
                return -1; //MAS_ERROR_OPERATION_FAILED;
        }