[Coverity 1050274,1050277][SVACE/414964] Array out of bound
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 3 Apr 2019 00:48:38 +0000 (09:48 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Wed, 3 Apr 2019 02:53:03 +0000 (11:53 +0900)
This fixes array out of bound access found by the three incidents.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
gst/nnstreamer/tensor_source/tensor_src_iio.c

index 29c74a6..6507a4b 100644 (file)
@@ -484,15 +484,16 @@ gst_tensor_src_merge_tensor_by_type (GstTensorInfo * info, guint size,
         merge_dim = dim_idx + 1;
         break;
       }
-      /** No outer dimension available to merge */
-      if (merge_dim > NNS_TENSOR_RANK_LIMIT) {
-        return size;
-      }
     }
   } else {
     return -1;
   }
 
+  /** No outer dimension available to merge */
+  if (merge_dim >= NNS_TENSOR_RANK_LIMIT || merge_dim < 0) {
+    return size;
+  }
+
   /** Now merge into 1 tensor using the selected dimension*/
   info[0].dimension[merge_dim] = size;
   return 1;