The following issues were found

caffe2/operators/generate_proposals_op_util_boxes_test.cc
1 issues
syntax error
Error

Line: 40

                EXPECT_NEAR((result.matrix() - result_gt).norm(), 0.0, 1e-4);
}

TEST(UtilsBoxesTest, TestBboxTransformRotated) {
  // Test rotated bbox transform w/o angle normalization
  using EMatXf = Eigen::MatrixXf;

  EMatXf bbox(5, 5);
  bbox << 214.986, 88.4628, 78.7317, 135.104, 0.0, 199.553, 55.4367, 60.6142,

            

Reported by Cppcheck.

caffe2/operators/generate_proposals_op_test.cc
1 issues
syntax error
Error

Line: 63

                return;
}

TEST(GenerateProposalsTest, TestComputeAllAnchors) {
  ERMatXf anchors(3, 4);
  anchors << -38, -16, 53, 31, -84, -40, 99, 55, -176, -88, 191, 103;

  int height = 4;
  int width = 3;

            

Reported by Cppcheck.

caffe2/operators/generate_proposals_op_gpu_test.cc
1 issues
syntax error
Error

Line: 82

                tensor->CopyFrom(tmp);
}

TEST(GenerateProposalsTest, TestRealDownSampledGPU) {
  if (!HasCudaGPU())
    return;
  Workspace ws;
  OperatorDef def;
  def.set_name("test");

            

Reported by Cppcheck.

caffe2/operators/gather_ranges_to_dense_op.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 158 Column: 18 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                            });
          for (int b_i = 0; b_i < rangeLength; ++b_i) {
            // Since this CPU only, directly copy to the destination.
            std::memcpy(
                outputRawData[j] + (i * lengths_[j] + b_i) * itemsize,
                buffer[b_i].second,
                itemsize);
          }
        }

            

Reported by FlawFinder.

caffe2/operators/fused_rowwise_nbitfake_conversion_ops.cc
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 75 Column: 3 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

              
namespace internal {
void convertfp32fp32(float* dst, const float* src, size_t N) {
  memcpy(dst, src, sizeof(float) * N);
}

void convertfp16fp32(float* dst, const at::Half* src, size_t N) {
  for (size_t i = 0; i < N; i++) {
    dst[i] = src[i];

            

Reported by FlawFinder.

caffe2/operators/dataset_ops.cc
1 issues
mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 64 Column: 16 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                    auto lf = nameParts.at(lenField.id);
      auto lfEnd = lf.end() - 1;
      // check whether this lengthField is a prefix for this field name
      if (std::mismatch(lf.begin(), lfEnd, nameParts.at(field.id).begin())
              .first != lfEnd) {
        continue;
      }
      if (lf.size() > maxMatchLevel) {
        maxMatchLevel = lf.size();

            

Reported by FlawFinder.

caffe2/operators/conv_transpose_op_cudnn.cc
1 issues
Unmatched '('. Configuration: ''.
Error

Line: 813

                    order_ == StorageOrder::NCHW ? C / group_ * Y_HxW : C / group_;
  const int group_offset_filter = filter.numel() / group_;
  for (int i = 0; i < group_; ++i) {
    cudnn_wrapper_.with_cudnn_state(cudnn_state_, [&](CuDNNState* state) {
      CUDNN_ENFORCE(cudnnConvolutionBackwardFilter(
          state->cudnn_handle(),
          cudnnTypeWrapper<T>::kOne(),
          top_desc_,
          dY.template data<T>() + i * group_offset_Y,

            

Reported by Cppcheck.

caffe2/operators/conv_op_cache_cudnn_test.cc
1 issues
syntax error
Error

Line: 24

                EXPECT_EQ(res2, 5);
}

TEST(AlgorithmsCacheTest, KeysDifferIfOneVectorIsEmpty) {
  AlgorithmsCache<int> cache;
  int result = cache.getAlgorithm(
      std::vector<int64_t>(1, 10), std::vector<int64_t>(), 0, []() { return 5; });
  EXPECT_EQ(result, 5);


            

Reported by Cppcheck.

caffe2/operators/cc_bmm_bg_op.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 112 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                    // concat input to scratch
      for (int i = 1; i < InputSize(); ++i) {
        auto* input_data = Input(i).template data<T>();
        memcpy(
            &scratch_input[(i - 1) * embed_size],
            input_data + b * embed_size,
            embed_size * Input(i).itemsize());
      }
      // call mkl gemm

            

Reported by FlawFinder.

caffe2/operators/cast_op.cc
1 issues
Uninitialized variable: data
Error

Line: 25 CWE codes: 908

                auto& input = Input(0);

  auto* output = Output(0, input.sizes(), at::dtype<DstType>());
  const auto* data = input.template data<SrcType>();
  auto* out = output->template mutable_data<DstType>();
  auto N = input.numel();
  for (int64_t i = 0; i < N; ++i) {
    out[i] = CastHelper<DstType, SrcType>::call(data[i]);
  }

            

Reported by Cppcheck.