"Nesselhauf, John" wrote:
> 
> This not C++ but olny C. code  beleow
> 
> UInt CalcCRC(int typeStruct, UChar * cecho, int bytecount )
> {
>         int i;
>         char *d_ptr, *end_p;
>         unsigned short int t1, t2, crc = 0;
>         char f1, f2;
> 
>         switch(typeStruct)
>         {
>                 case 1:
>                         end_p = (char *)cecho;
>                         d_ptr = (char *)cecho;
>                         end_p += 2;
>                         end_p += bytecount;
>                 break;
>                 case 2:
>                         end_p = (char *)cecho;
>                         d_ptr = (char *)cecho;

[snip]

I see nothing in that code that makes sure you don't overrun the buffer
pointed to by cecho.  In the debugger, when it crashes, try checking
bytecount and the value of (end_p - cecho).  If the latter is bigger
than the former, or if bytecount isn't actually the number of bytes
pointed to by cecho, you will get memory errors.

--
= Warren Young -- Maintainer of the Palm OS Programmer's FAQ at:
=     http://www.cyberport.com/~tangent/palm/faq/
=
= ICBM Address: 36.8274040 N, 108.0204086 W, alt. 1714m

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to