sisimma
Fri Mar 07 14:21:00 CST 2008
Thanks all.
that's what I found yesterday too.
It should have been (tcslen(lptemp) * sizeof(TCHAR))
Have a good day every moment
"<ctacke/>" wrote:
> Or even (tcslen(lptemp) * sizeof(TCHAR))
>
>
> --
>
> Chris Tacke, eMVP
> Join the Embedded Developer Community
>
http://community.opennetcf.com
>
>
> "Michael Salamone" <mikesa#at#entrek#dot#com> wrote in message
> news:F51D337F-0C02-4475-AD19-3F0DB4B255EF@microsoft.com...
> > Usually heap corruption causes that. And that's what your problem is.
> > You are allocating sizeof(lptemp) but you really want tcslen(lptemp).
> > sizeof() will return 4 - the size of a pointer. You want the length of
> > the string that the pointer is pointing to, which is what tcslen will give
> > you. Since you only allocated 4, you're overrunning the buffer in the
> > call to tcscpy (assuming the string has length greater than 4).
> >
> > --
> > Michael Salamone, eMVP
> > Entrek Software, Inc.
> > www.entrek.com
> >
> >
> > "sisimma" <sisimma@discussions.microsoft.com> wrote in message
> > news:2FE181FF-570E-49CD-9E3F-D925D734386E@microsoft.com...
> >> Hi,
> >> I'm using LocalAlloc() in my application running Windows mobile 6.
> >> When this is used in a Dialog class and another class member function is
> >> called with an argument pointing the allocated memory, it meets 'data
> >> abort'
> >> several steps after going into the callee class thesm.MaSMSdispatch().
> >>
> >> what is this making this data abort?
> >> Please let me know how I should use memory management between classes.
> >> thanks you.
> >>
> >> <here is the part of my codes.>
> >> iService.sms_recipient.lpmsisdn=(TCHAR*)::LocalAlloc(GPTR,sizeof(lptemp)+1);
> >> iService.sms_recipient.lpmsisdn[sizeof(lptemp)]=0;
> >> _tcscpy(iService.sms_recipient.lpmsisdn,lptemp);
> >>
> >> thesm.MaSMSdispatch( hDlg,(void *)&iService);
> >>
> >> ::LocalFree(iService.sms_recipient.lpmsisdn);
> >>
> >> <error message>
> >> Data Abort: Thread=82ec47b4 Proc=803e8410 'cmob01.exe'
> >> AKY=00200001 PC=0002f630(cmob01.exe+0x0001f630)
> >> RA=0002f3a4(cmob01.exe+0x0001f3a4) BVA=2c37009a FSR=00000001
> >> The program '[c3221272] cmob01.exe' has exited with code 1067 (0x42b).
> >
>
>
>