Handle exception cases to BindBackend 36/233236/3
authorInki Dae <inki.dae@samsung.com>
Wed, 13 May 2020 07:04:55 +0000 (16:04 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 13 May 2020 08:54:14 +0000 (17:54 +0900)
This patch handles below two exception cases properly,
 - A case that user calls BindBackend second time.
 - A case that user calls BIndBackend with null parameter.

Change-Id: Ia104226b81b5fcb56fe0111a5d74f27ec4d0ed01
Signed-off-by: Inki Dae <inki.dae@samsung.com>
src/inference_engine_common_impl.cpp

index b6707e2..8ef900d 100755 (executable)
@@ -203,6 +203,16 @@ int InferenceEngineCommon::BindBackend(inference_engine_config *config)
 {
     LOGI("ENTER");
 
+       if (mBackendHandle) {
+               LOGE("Already backend engine has been initialized.");
+               return INFERENCE_ENGINE_ERROR_INVALID_OPERATION;
+       }
+
+       if (config == nullptr) {
+               LOGE("config object is invalid.");
+               return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER;
+       }
+
        if (mUseProfiler == true) {
                // Memory usage will be measured between BindBackend ~ UnbindBackend callbacks.
                mProfiler->Start(IE_PROFILER_MEMORY);