@@ -99,12 +99,12 @@ static bool zlib_stream_decompress_data_to_file_init(
9999 void * context , file_archive_file_handle_t * handle ,
100100 const uint8_t * cdata , unsigned cmode , uint32_t csize , uint32_t size )
101101{
102- zip_context_t * zip_context = (zip_context_t * )context ;
103- struct file_archive_transfer * state = zip_context -> state ;
104- uint8_t local_header_buf [4 ];
102+ int64_t offsetData ;
105103 uint8_t * local_header ;
106104 uint32_t offsetNL , offsetEL ;
107- int64_t offsetData ;
105+ uint8_t local_header_buf [4 ];
106+ zip_context_t * zip_context = (zip_context_t * )context ;
107+ struct file_archive_transfer * state = zip_context -> state ;
108108
109109 /* free previous data and stream if left unfinished */
110110 zip_context_free_stream (zip_context , false);
@@ -118,7 +118,10 @@ static bool zlib_stream_decompress_data_to_file_init(
118118 {
119119 filestream_seek (state -> archive_file , (int64_t )(size_t )cdata + 26 , RETRO_VFS_SEEK_POSITION_START );
120120 if (filestream_read (state -> archive_file , local_header_buf , 4 ) != 4 )
121- goto error ;
121+ {
122+ zip_context_free_stream (zip_context , false);
123+ return false;
124+ }
122125 local_header = local_header_buf ;
123126 }
124127
@@ -156,34 +159,31 @@ static bool zlib_stream_decompress_data_to_file_init(
156159 {
157160 free (zip_context -> zstream );
158161 zip_context -> zstream = NULL ;
159- goto error ;
162+ zip_context_free_stream (zip_context , false);
163+ return false;
160164 }
161165 }
162166
163167 return true;
164-
165- error :
166- zip_context_free_stream (zip_context , false);
167- return false;
168168}
169169
170170static int zlib_stream_decompress_data_to_file_iterate (
171171 void * context , file_archive_file_handle_t * handle )
172172{
173+ int64_t rd ;
173174 zip_context_t * zip_context = (zip_context_t * )context ;
174175 struct file_archive_transfer * state = zip_context -> state ;
175- int64_t rd ;
176176
177177 if (zip_context -> cmode == ZIP_MODE_STORED )
178178 {
179- #ifdef HAVE_MMAP
179+ #ifdef HAVE_MMAP
180180 /* Simply copy the data to the output buffer */
181181 if (zip_context -> state -> archive_mmap_data )
182182 memcpy (zip_context -> decompressed_data ,
183- zip_context -> state -> archive_mmap_data + (size_t )zip_context -> fdoffset ,
184- zip_context -> usize );
183+ zip_context -> state -> archive_mmap_data + (size_t )zip_context -> fdoffset ,
184+ zip_context -> usize );
185185 else
186- #endif
186+ #endif
187187 {
188188 /* Read the entire file to memory */
189189 filestream_seek (state -> archive_file , zip_context -> fdoffset , RETRO_VFS_SEEK_POSITION_START );
@@ -204,15 +204,15 @@ static int zlib_stream_decompress_data_to_file_iterate(
204204 if (!zip_context -> zstream )
205205 return 1 ;
206206
207- #ifdef HAVE_MMAP
207+ #ifdef HAVE_MMAP
208208 if (state -> archive_mmap_data )
209209 {
210210 /* Decompress from the mapped file */
211211 dptr = state -> archive_mmap_data + (size_t )zip_context -> fdoffset + zip_context -> boffset ;
212212 rd = to_read ;
213213 }
214214 else
215- #endif
215+ #endif
216216 {
217217 /* Read some compressed data from file to the temp buffer */
218218 filestream_seek (state -> archive_file ,
0 commit comments