On 17/06/11 16:45, Stephanie Stroka wrote:

> I actually ignored three warnings. It's still a bit cryptic for me. For
> example, I get the following msg:
>
> Invalid write of size 4
> ==4427==    at 0x405930: sort(unsigned int**, unsigned int, unsigned
> int) (facedetect.cpp:293)
> ==4427==    by 0x407EA9: findScrambledArea(cv::Mat&) (facedetect.cpp:536)
> ==4427==    by 0x40AFFD: runOperation(Mode, CryptoKey const&,
> DetectorParams&, std::string, std::string, std::string, bool)
> (facedetect.cpp:625)
> ==4427==    by 0x40BCD8: main (facedetect.cpp:700)
> ==4427==  Address 0x11154010 is 0 bytes after a block of size 2,080 alloc'd
> ==4427==    at 0x4C2668A: malloc (vg_replace_malloc.c:236)
> ==4427==    by 0x4058CE: sort(unsigned int**, unsigned int, unsigned
> int) (facedetect.cpp:287)
> ==4427==    by 0x407EA9: findScrambledArea(cv::Mat&) (facedetect.cpp:536)
> ==4427==    by 0x40AFFD: runOperation(Mode, CryptoKey const&,
> DetectorParams&, std::string, std::string, std::string, bool)
> (facedetect.cpp:625)
> ==4427==    by 0x40BCD8: main (facedetect.cpp:700)
>
>
> My code at that position looks like this:
>
> 284 static uint* sort(uint** matrix, uint width, uint height) {
> 285     uint* data = (uint*) malloc(width * height * sizeof(uint));
> 286     uint i,j=0;
> 287     for(i=0; i<height; i++) {
> 288         for(j=0; j<width; j++) {
> 289             data[j + i*height] = matrix[i][j];
> 290         }
> 291     }
> ...
>
> I don't see why I'm using an invalid write of size 4. I'm retrieving an
> uint and I'm writing an uint.

The write it is complaining about is at line 293 and you haven't shown 
us that line ;-)

What it is saying is that you are writing beyond the end of the array.

Tom

-- 
Tom Hughes (t...@compton.nu)
http://compton.nu/

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to