@@ -61,15 +61,13 @@ typedef struct
6161 uint8_t * decompressed_data ;
6262} zip_context_t ;
6363
64- static INLINE uint32_t read_le (const uint8_t * data , unsigned size )
64+ static INLINE uint32_t read_le (const uint8_t * data , size_t len )
6565{
6666 unsigned i ;
6767 uint32_t val = 0 ;
68-
69- size *= 8 ;
70- for (i = 0 ; i < size ; i += 8 )
68+ len *= 8 ;
69+ for (i = 0 ; i < len ; i += 8 )
7170 val |= (uint32_t )* data ++ << i ;
72-
7371 return val ;
7472}
7573
@@ -114,9 +112,7 @@ static bool zlib_stream_decompress_data_to_file_init(
114112 /* seek past most of the local directory header */
115113#ifdef HAVE_MMAP
116114 if (state -> archive_mmap_data )
117- {
118115 local_header = state -> archive_mmap_data + (size_t )cdata + 26 ;
119- }
120116 else
121117#endif
122118 {
@@ -181,13 +177,11 @@ static int zlib_stream_decompress_data_to_file_iterate(
181177 if (zip_context -> cmode == ZIP_MODE_STORED )
182178 {
183179 #ifdef HAVE_MMAP
180+ /* Simply copy the data to the output buffer */
184181 if (zip_context -> state -> archive_mmap_data )
185- {
186- /* Simply copy the data to the output buffer */
187182 memcpy (zip_context -> decompressed_data ,
188183 zip_context -> state -> archive_mmap_data + (size_t )zip_context -> fdoffset ,
189184 zip_context -> usize );
190- }
191185 else
192186 #endif
193187 {
@@ -204,27 +198,26 @@ static int zlib_stream_decompress_data_to_file_iterate(
204198 }
205199 else if (zip_context -> cmode == ZIP_MODE_DEFLATED )
206200 {
207- int to_read = MIN (zip_context -> csize - zip_context -> boffset , _READ_CHUNK_SIZE );
208201 uint8_t * dptr ;
202+ int to_read = MIN (zip_context -> csize - zip_context -> boffset , _READ_CHUNK_SIZE );
203+ /* File was uncompressed or decompression finished before */
209204 if (!zip_context -> zstream )
210- {
211- /* file was uncompressed or decompression finished before */
212205 return 1 ;
213- }
214206
215207 #ifdef HAVE_MMAP
216208 if (state -> archive_mmap_data )
217209 {
218210 /* Decompress from the mapped file */
219211 dptr = state -> archive_mmap_data + (size_t )zip_context -> fdoffset + zip_context -> boffset ;
220- rd = to_read ;
212+ rd = to_read ;
221213 }
222214 else
223215 #endif
224216 {
225217 /* Read some compressed data from file to the temp buffer */
226- filestream_seek (state -> archive_file , zip_context -> fdoffset + zip_context -> boffset ,
227- RETRO_VFS_SEEK_POSITION_START );
218+ filestream_seek (state -> archive_file ,
219+ zip_context -> fdoffset + zip_context -> boffset ,
220+ RETRO_VFS_SEEK_POSITION_START );
228221 rd = filestream_read (state -> archive_file , zip_context -> tmpbuf , to_read );
229222 if (rd < 0 )
230223 return -1 ;
@@ -365,7 +358,6 @@ static int64_t zip_file_read(
365358 file_archive_transfer_t state = {0 };
366359 decomp_state_t decomp = {0 };
367360 struct archive_extract_userdata userdata = {0 };
368- bool returnerr = true;
369361 int ret = 0 ;
370362
371363 if (needle )
@@ -380,6 +372,7 @@ static int64_t zip_file_read(
380372
381373 do
382374 {
375+ bool returnerr = true;
383376 ret = file_archive_parse_file_iterate (& state , & returnerr , path ,
384377 "" , zip_file_decompressed , & userdata );
385378 if (!returnerr )
@@ -522,13 +515,13 @@ static int zip_parse_file_iterate_step(void *context,
522515 file_archive_file_cb file_cb )
523516{
524517 zip_context_t * zip_context = (zip_context_t * )context ;
525- const uint8_t * cdata = NULL ;
526- uint32_t checksum = 0 ;
527- uint32_t size = 0 ;
528- uint32_t csize = 0 ;
529- unsigned cmode = 0 ;
530- unsigned payload = 0 ;
531- int ret = zip_parse_file_iterate_step_internal (zip_context ,
518+ const uint8_t * cdata = NULL ;
519+ uint32_t checksum = 0 ;
520+ uint32_t size = 0 ;
521+ uint32_t csize = 0 ;
522+ unsigned cmode = 0 ;
523+ unsigned payload = 0 ;
524+ int ret = zip_parse_file_iterate_step_internal (zip_context ,
532525 userdata -> current_file_path , & cdata , & cmode , & size , & csize , & checksum , & payload );
533526
534527 if (ret != 1 )
0 commit comments