mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	ok, tweaking the fclose leak fix on write failure so it occurs AFTER the src file is opened, to prevent the dest archive from expanding in case the src file is missing (should be harmless though)
This commit is contained in:
		
							
								
								
									
										10
									
								
								miniz.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								miniz.c
									
									
									
									
									
								
							| @@ -4439,10 +4439,7 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, | |||||||
|  |  | ||||||
|   if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) |   if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) | ||||||
|     return MZ_FALSE; |     return MZ_FALSE; | ||||||
|  |      | ||||||
|   if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) |  | ||||||
|     return MZ_FALSE; |  | ||||||
|  |  | ||||||
|   pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); |   pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); | ||||||
|   if (!pSrc_file) |   if (!pSrc_file) | ||||||
|     return MZ_FALSE; |     return MZ_FALSE; | ||||||
| @@ -4459,6 +4456,11 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, | |||||||
|   if (uncomp_size <= 3) |   if (uncomp_size <= 3) | ||||||
|     level = 0; |     level = 0; | ||||||
|  |  | ||||||
|  |   if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) | ||||||
|  |   { | ||||||
|  |     MZ_FCLOSE(pSrc_file); | ||||||
|  |     return MZ_FALSE; | ||||||
|  |   } | ||||||
|   local_dir_header_ofs += num_alignment_padding_bytes; |   local_dir_header_ofs += num_alignment_padding_bytes; | ||||||
|   if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } |   if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } | ||||||
|   cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); |   cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user