engine: net_chan: check BZ2 functions return value and log if it's not BZ_OK
This commit is contained in:
parent
888599677e
commit
df4194ca57
1 changed files with 13 additions and 5 deletions
|
@ -754,7 +754,7 @@ static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg )
|
|||
byte pbOut[0x10000];
|
||||
uint uSourceSize = MSG_GetNumBytesWritten( msg );
|
||||
uint uCompressedSize = MSG_GetNumBytesWritten( msg ) - 4;
|
||||
if( !BZ2_bzBuffToBuffCompress( pbOut, &uCompressedSize, MSG_GetData( msg ), uSourceSize, 9, 0, 30 ))
|
||||
if( BZ2_bzBuffToBuffCompress( pbOut, &uCompressedSize, MSG_GetData( msg ), uSourceSize, 9, 0, 30 ) == BZ_OK )
|
||||
{
|
||||
if( uCompressedSize < uSourceSize )
|
||||
{
|
||||
|
@ -1180,12 +1180,20 @@ qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *l
|
|||
#if !XASH_DEDICATED
|
||||
byte buf[0x10000];
|
||||
uint uDecompressedLen = sizeof( buf );
|
||||
int bz2_err = BZ2_bzBuffToBuffDecompress( buf, &uDecompressedLen, MSG_GetData( msg ) + 4, MSG_GetNumBytesWritten( msg ) - 4, 1, 0 );
|
||||
|
||||
BZ2_bzBuffToBuffDecompress( buf, &uDecompressedLen, MSG_GetData( msg ) + 4, MSG_GetNumBytesWritten( msg ) - 4, 1, 0 );
|
||||
memcpy( msg->pData, buf, uDecompressedLen );
|
||||
size = uDecompressedLen;
|
||||
if( bz2_err == BZ_OK )
|
||||
{
|
||||
size = uDecompressedLen;
|
||||
memcpy( msg->pData, buf, size );
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: BZ2 decompression failed (%d)\n", __func__, bz2_err );
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
|
||||
Host_Error( "%s: BZ2 compression is not supported for server\n", __func__ );
|
||||
#endif
|
||||
}
|
||||
else if( !chan->use_bz2 && LZSS_IsCompressed( MSG_GetData( msg ), size ))
|
||||
|
|
Loading…
Add table
Reference in a new issue