apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad Nicholes" <BNICHO...@novell.com>
Subject problem with teststr
Date Thu, 19 Dec 2002 00:04:21 GMT
   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

View raw message