From: molivier Date: Mon, 9 Feb 2004 09:26:45 +0000 (+0000) Subject: The test used in the FS_Read function to detect the end of a compressed file was... X-Git-Tag: xonotic-v0.1.0preview~6105 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a0fbecb998b153b0840d5a4910e2c7b2a8df38ab;p=xonotic%2Fdarkplaces.git The test used in the FS_Read function to detect the end of a compressed file was incorrect, causing some big files to be truncated when unzipped. Many thanks to Fuh for poiting out this mistake to me git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3883 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/fs.c b/fs.c index b8fd9a61..2a5ea5a8 100644 --- a/fs.c +++ b/fs.c @@ -1344,12 +1344,13 @@ size_t FS_Read (qfile_t* file, void* buffer, size_t buffersize) // If "input" is also empty, we need to fill it if (ztk->in_ind == ztk->in_max) { - size_t remain = file->length - ztk->in_position; + size_t remain; // If we are at the end of the file - if (!remain) + if (ztk->out_position == ztk->real_length) return nb; + remain = file->length - ztk->in_position; count = (remain > sizeof (ztk->input)) ? sizeof (ztk->input) : remain; fread (ztk->input, 1, count, file->stream);