2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-21 17:37:32 +01:00

filesystem: fix zip_t and pack_t definition so it have true standard flexible array member

This commit is contained in:
Alibek Omarov 2024-08-08 06:14:06 +03:00
parent bd2a44dbdd
commit d2d6ed8bd4
2 changed files with 4 additions and 4 deletions

View File

@ -69,7 +69,7 @@ struct pack_s
{
file_t *handle;
int numfiles;
dpackfile_t files[1]; // flexible
dpackfile_t files[]; // flexible
};
/*
@ -150,7 +150,7 @@ static pack_t *FS_LoadPackPAK( const char *packfile, int *error )
return NULL;
}
pack = (pack_t *)Mem_Calloc( fs_mempool, sizeof( pack_t ) + sizeof( dpackfile_t ) * ( numpackfiles - 1 ));
pack = (pack_t *)Mem_Calloc( fs_mempool, sizeof( pack_t ) + sizeof( dpackfile_t ) * numpackfiles );
FS_Seek( packhandle, header.dirofs, SEEK_SET );
if( header.dirlen != FS_Read( packhandle, (void *)pack->files, header.dirlen ))

View File

@ -125,7 +125,7 @@ struct zip_s
{
file_t *handle;
int numfiles;
zipfile_t files[1]; // flexible
zipfile_t files[]; // flexible
};
// #define ENABLE_CRC_CHECK // known to be buggy because of possible libpublic crc32 bug, disabled
@ -285,7 +285,7 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
FS_Seek( zip->handle, header_eocd.central_directory_offset, SEEK_SET );
// Calc count of files in archive
zip = (zip_t *)Mem_Realloc( fs_mempool, zip, sizeof( *zip ) + sizeof( *info ) * ( header_eocd.total_central_directory_record - 1 ));
zip = (zip_t *)Mem_Realloc( fs_mempool, zip, sizeof( *zip ) + sizeof( *info ) * header_eocd.total_central_directory_record );
info = zip->files;
for( i = 0; i < header_eocd.total_central_directory_record; i++ )