apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@apache.org>
Subject Re: problem with teststr
Date Thu, 19 Dec 2002 17:44:24 GMT

I fixed this last night by adding CuAssertStrNEquals.  This bug has bitten
me on Windows too.

Thanks for pointing me in the right direction.


On Wed, 18 Dec 2002, Brad Nicholes wrote:

>    It appears that the snprintf_noNULL() test in teststr will always
> fails.  Since apr_palloc() is not guaranteed to return initialized
> memory (which I think is why the test is written this way), after
> initializing the memory with the string "testing", the remaining 3 bytes
> can be garbage.  After the call to apr_snprintf(), buffer contains a
> valid string but testing still has 3 bytes of garbage.
> CuAssertStrEquals() uses the function strcmp() to validate that the
> value returned in buff matches the value in testing.  The problem is
> that testing still contains those 3 garbage bytes which means that the
> comparison of the two value will never match.  Shouldn't testing be NULL
> terminated before calling CuAssertStrEquals()?
> Brad Nicholes
> Senior Software Engineer
> Novell, Inc., the leading provider of Net business solutions
> http://www.novell.com

View raw message