#5 Array Index out of bounds

closed-fixed
Trilarion
None
3
2009-11-23
2006-09-19
Mark Bryan Yu
No

in MainFrm.cpp

CMainFrame::CreateMinimizedMenu(BCMenu *pMainMenu,
BCMenu *pMinimize)

1. char *pTemp = (char *) malloc (note->GetTitle
().GetLength () + 1);
2. for (i = 0; i < note->GetTitle ().GetLength (); i++)
3. pTemp[i] = note->GetTitle ().GetAt (i);
4. pTemp [note->GetTitle ().GetLength () + 1] = '\0';
5. TCHAR* szWide = A2T( pTemp );
6. delete pTemp;

line 4 should be

pTemp [note->GetTitle ().GetLength ()] = '\0';

should also use free instead of delete since malloc was
used or use new instead of malloc.

char *pTemp = new char[note->GetTitle ().GetLength ()+1];

delete[] pTemp; //put before the if statement ends

Discussion

  • Trilarion
    Trilarion
    2009-11-23

    After a long time...

    Seems valid and is fixed in current svn version. Thanks. :)

     
  • Trilarion
    Trilarion
    2009-11-23

    • priority: 5 --> 3
    • assigned_to: nobody --> trilarion
    • status: open --> closed-fixed