[Trivial] Fix svace issue
authorSeoHyungjun <hyungjun.seo@samsung.com>
Fri, 16 Dec 2022 07:14:16 +0000 (16:14 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 22 Dec 2022 03:11:23 +0000 (12:11 +0900)
The for loop runs only once due to a return.
To resolve this issue, we added a conditional statement to run return when it is not ML_ERROR_NONE.

Signed-off-by: SeoHyungjun <hyungjun.seo@samsung.com>
api/capi/src/nntrainer.cpp

index b5ace04..efe71d8 100644 (file)
@@ -1286,7 +1286,10 @@ int ml_train_model_get_weight(ml_train_model_h model, const char *layer_name,
   for (unsigned int i = 0; i < dims.size(); ++i) {
     status = ml_tensors_data_set_tensor_data(
       *weight, i, w[i], dims[i].getDataLen() * sizeof(float));
-    return status;
+    if (status != ML_ERROR_NONE) {
+           ml_tensors_data_destroy(weight);
+      return status;
+    }
   }
 
   return status;