diff --git a/engine/common/net_chan.c b/engine/common/net_chan.c index c690181c..f1dd50da 100644 --- a/engine/common/net_chan.c +++ b/engine/common/net_chan.c @@ -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 ))