CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Posts
    25

    debug error: damage:after normal block..

    Hi,
    i have a dynamic byte array "ba". i have used it as follows

    BYTE *ba = new BYTE[len]; //len is non zero

    ZeroMemory(ba, sizeof(ba)*(len));

    memcpy(ba,p_btPgBodyPtr+f_dwStrtTblOff,len);

    ...
    ....
    ....

    if(ba)
    delete [] ba; //i get debug error out here

    can anybody help me solve this problem

    thanks
    Last edited by jude_aj; April 6th, 2009 at 11:15 AM.

  2. #2
    Join Date
    Mar 2009
    Posts
    51

    Re: debug error: damage:after normal block..

    Code:
    BYTE *ba = new BYTE[len];
     
    ZeroMemory(ba, sizeof(ba)*(len));
    You are allocating far less bytes (len) than you are using (sizeof(ba)*len).

    Note that sizeof(ba) is 'size of pointer to byte' and is not 'size of byte'.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured