在valgrind中读取大小为8的读取无效

时间:2015-02-27 10:03:10

标签: c++ valgrind

Valgrind显示以下错误消息

==8584== Invalid read of size 8
==8584==  at0x4CA885D:VPR::VidSegment::getMCmean(std::vector<std::vector<CvRect, std::allocator<CvRect> >, std::allocator<std::vector<CvRect, std::allocator<CvRect> > > > const&) const (VidSegment.cpp:678)

==8584==    by 0x4CAE071: VPR::VidSegment::getSegments(std::vector<CvRect, std::allocator<CvRect> >, _IplImage const*) (VidSegment.cpp:234)


  vector<CvRect> VidSegment::getMCmean(const vector< vector<CvRect> >& majorCluster) const
  {
    vector<CvRect> meanvaluesN;

    for (int i = 0; i < (int) majorCluster.size(); i++ )
    {
      int sumH=0, sumY=0, sumW=0, sumB=0;
      vector<CvRect> tempV = majorCluster[i];
      //Here-------------->
      for (int j = 0; j < (int) tempV.size(); j++)
      {
        sumH +=  tempV[j].height;
        sumW +=  tempV[j].width;
        sumY +=  tempV[j].y;
        sumB += (tempV[j].y + tempV[j].height);
      }
      sumH /= tempV.size();
      sumY /= tempV.size();
      sumW /= tempV.size();
      sumB /= tempV.size();
      meanvaluesN.push_back(cvRect(sumH, sumY, sumW, sumB));
    }
    return meanvaluesN;
  }

我无法找到显示上述信息的原因。

有人可以说出原因吗?

我也收到以下错误消息

==8584== Address 0x960107c is 252 bytes inside a block of size 256 alloc'd 
==8584== at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298) 

==8584== by 0x4CA87A4: VPR::VidSegment::getMCmean(std::vector<std::vector<CvRect, std::allocator<CvRect> >, std::allocator<std::vector<CvRect, std::allocator<CvRect> > > > const&) const (new_allocator.h:89) 

0 个答案:

没有答案