From: BJ H. <par...@us...> - 2004-02-09 18:05:43
|
Log Message: ----------- Fix for network string changes Modified Files: -------------- /cvsroot/decaldev/source/DecalNet: MessageLoaders.cpp Revision Data ------------- Index: MessageLoaders.cpp =================================================================== RCS file: /cvsroot/decaldev/source/DecalNet/MessageLoaders.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MessageLoaders.cpp 12 Apr 2002 01:07:34 -0000 1.2 +++ MessageLoaders.cpp 9 Feb 2004 18:02:30 -0000 1.3 @@ -138,22 +138,34 @@ if( ( reinterpret_cast< BYTE * >( pvData ) + wField ) > reinterpret_cast< BYTE * >( pvEnd ) ) return false; - if( *( reinterpret_cast< char * >( pvData ) + wLength - 1 ) != '\0' ) + // Strings are no longer NULL-Terminated in the stream + //if( *( reinterpret_cast< char * >( pvData ) + wLength - 1 ) != '\0' ) // This string is not NULL terminated - return false; + // return false; // Anything else just makes the string ugly, but won't lead to a memory // overrun, so let them play return true; } - virtual void getValue( void *pvData, LPVARIANT pDest ) - { - USES_CONVERSION; + virtual void getValue( void *pvData, LPVARIANT pDest ) + { + pDest->vt = VT_BSTR; - pDest->vt = VT_BSTR; - pDest->bstrVal = A2BSTR( reinterpret_cast< char * >( reinterpret_cast< BYTE * >( pvData ) + sizeof( WORD ) ) ); - } + USES_CONVERSION; + WORD wLength = *(WORD *) pvData; + + // Save the byte where we're going to insert our null terminator :P + char *szString = (char *) (((BYTE*) pvData) + sizeof( WORD )); + BYTE byteSaved = szString[ wLength ]; + szString[ wLength ] = 0; + + // this is way more efficient then a new, memcpy, and delete. go us + pDest->bstrVal = A2BSTR( szString ); + + // put byte back :) + szString[ wLength ] = byteSaved; + } }; long cFieldLoader::getNumber( void *pvData ) |