[fdo-dev] [fdordbms] UnitTest segmentation fault
Mateusz Loskot
mateusz at loskot.net
Sat Oct 7 06:34:16 EDT 2006
Mateusz Loskot wrote:
>
> 3. I added my own test for NULL pointer to GetEnviron() function and for
> 'password' parameter only, it prints huge number of places where this
> variable is used
For completeness, here is what changes I applied to check these problem:
char *UnitTestUtil::GetEnviron(const char *name, const char *suffix)
{
char* pTest = const_cast<char*>(
UnitTestUtil::InfoUtilConnection->GetEnviron(name, suffix));
if (0 == pTest)
{
printf(" - UnitTestUtil::InfoUtilConnection->GetEnviron(\"%s\") ==
NULL\n", name);
}
return pTest;
}
By the way, I've also noticed some const-correctness inconsistency.
The lower-level function that calls getenv() is:
const char* ConnectionUtil::GetEnviron(const char *name, const char *suffix)
next, there is non-const function above:
char *UnitTestUtil::GetEnviron(const char *name, const char *suffix)
getenv() returns non-const pointer, so why UnitTestUtil::GetEnviron()
returns const char* if it's only a wrapper on the getenv()?
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the Fdo-internals
mailing list