[Svace] fix svace issue accepted/tizen/unified/20230808.074019
authorJaeyun Jung <jy1210.jung@samsung.com>
Fri, 4 Aug 2023 03:10:09 +0000 (12:10 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 4 Aug 2023 04:37:05 +0000 (13:37 +0900)
Check null case when getting nth info of ml and gst tensor-info.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
c/src/ml-api-inference-internal.c

index 98ccfab..335a064 100644 (file)
@@ -201,6 +201,18 @@ _ml_tensors_info_copy_from_ml (GstTensorsInfo * gst_info,
     GstTensorInfo *_gst_tensor_info =
         gst_tensors_info_get_nth_info (gst_info, i);
 
+    if (!_gst_tensor_info) {
+      G_UNLOCK_UNLESS_NOLOCK (*ml_info);
+      _ml_error_report_return (ML_ERROR_INVALID_PARAMETER,
+          "The parameter, gst_info, is invalid. It should be a valid GstTensorsInfo instance. This is probably an internal bug of ML API.");
+    }
+
+    if (!_ml_tensor_info) {
+      G_UNLOCK_UNLESS_NOLOCK (*ml_info);
+      _ml_error_report_return (ML_ERROR_INVALID_PARAMETER,
+          "The parameter, ml_info, is invalid. It should be a valid ml_tensors_info_s instance, usually created by ml_tensors_info_create(). This is probably an internal bug of ML API.");
+    }
+
     /* Copy name string */
     if (_ml_tensor_info->name) {
       _gst_tensor_info->name = g_strdup (_ml_tensor_info->name);