Hi,

Wrong forum but Im a newbie in Linux and this is a Linux compiler problem
(works on Watcom C++ 11/ MS VC++ 6.0). If someone knows a better place let
me know.

The code looks something like this:

///////////////////////////////////////
//
        const char *pek;
        for( loopIP = IPList.GetFirstNode(); loopIP; loopIP = loopIP->GetNext())
        {
                if( bMajor ) pek = strrchr( loopIP->GetHolder().strDNS, '.' );
                else pek = strchr( loopIP->GetHolder().strDNS, '.' );
                if( !pek ) pek = " <N/A> ";

fprintf( stderr, "1) pek = \"%s\"\n", pek ); // ** Still ok here **

                for( loopDNS = tList.GetFirstNode(); loopDNS; loopDNS =
loopDNS->GetNext())
                {
                        if( strcmp( pek, loopDNS->GetHolder().strDNS ) == 0 ) break;
                        else fprintf( stderr, "2) pek = \"%s\"\n", pek ); // ** NOT 
here **
                }

fprintf( stderr, "3) pek = \"%s\"\n", pek ); // If point 2 was executed then
pek is fucked up here

                if( loopDNS ) loopDNS->GetPointer()->iCount += 
loopIP->GetHolder().iCount;
                else
                {
                        sDNS sTemp;
                        if( strlen( pek ) < sizeof( sTemp.strDNS ) - 1)
                        {
fprintf( stderr, "4) pek = \"%s\"\n", pek ); // If point 2 was executed then
pek is still bad
                                strcpy( sTemp.strDNS, pek );
                                sTemp.iCount = loopIP->GetHolder().iCount;
                                tList.Append( sTemp );
fprintf( stderr, "5) pek = \"%s\"\n", pek ); // Pek is the same here as it
was at point 1, but the bad data is allready copied to sTemp.strDNS
                        }
                        else fprintf( stderr, "** ERROR ** Overflow detected." );
                }
        }

//
///////////////////////////////////////

It seems that "pek" is moved by strcmp(...) to point at bogus data if the
strings are not the same. But after a few commands the compiler restores the
value. Maybe strcmp(...) does not restore all registers at exit. And after a
while the compiler desides to restore them instead.

Or Im I doing something wrong?

// Jarmo

Reply via email to