diff --git a/filesystem/pak.c b/filesystem/pak.c index 8ca8b415..911458d3 100644 --- a/filesystem/pak.c +++ b/filesystem/pak.c @@ -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 )) diff --git a/filesystem/zip.c b/filesystem/zip.c index ed6eff87..56e53821 100644 --- a/filesystem/zip.c +++ b/filesystem/zip.c @@ -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++ )