Page 1 of 1

Bug in ClassEStd::StrCpy?

PostPosted: Jun 1, 2010 @ 11:13pm
by laughingkiwi

Re: Bug in ClassEStd::StrCpy?

PostPosted: Jun 8, 2010 @ 5:21pm
by edge
Hi,

The bug occurs because the destination array is too small for the 4 characters and the required NULL character at the end. The character array containing "ABCD" needs to be at least 5 bytes big.

Re: Bug in ClassEStd::StrCpy?

PostPosted: Jun 13, 2010 @ 1:39am
by laughingkiwi
So the answer is to use strncpy. I cannot increase the size of the buffer by 1 byte because it is part of a larger data structure. The only viable workaround is to use strncpy or possibly ClassEMemory::MemCpy instead of ClassEStd::StrCpy. I raised this as a possible bug to the different behaviour between StrCpy and strncpy which I thought would behave the same.