From ea7fb936a83d66d520ac45b110b0d74f9f29b136 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 May 2014 10:33:32 +0200 Subject: [PATCH] - fixed: memory allocation for file names in 7z archives was broken. Changing it to use TArray instead of alloca makes it work. --- src/resourcefiles/file_7z.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/resourcefiles/file_7z.cpp b/src/resourcefiles/file_7z.cpp index a7d173a4e6..53653bb59e 100644 --- a/src/resourcefiles/file_7z.cpp +++ b/src/resourcefiles/file_7z.cpp @@ -264,6 +264,8 @@ bool F7ZFile::Open(bool quiet) Lumps = new F7ZLump[NumLumps]; F7ZLump *lump_p = Lumps; + TArray nameUTF16; + TArray nameASCII; for (DWORD i = 0; i < NumLumps; ++i) { CSzFileItem *file = &Archive->DB.db.Files[i]; @@ -283,20 +285,16 @@ bool F7ZFile::Open(bool quiet) continue; } - // Convert UTF-16 filename to plain ASCII - - UInt16* const nameUTF16 = static_cast(alloca(sizeof(UInt16) * nameLength)); - SzArEx_GetFileNameUtf16(&Archive->DB, i, nameUTF16); - - char* const nameASCII = static_cast(alloca(nameLength)); - + nameUTF16.Resize(nameLength); + nameASCII.Resize(nameLength); + SzArEx_GetFileNameUtf16(&Archive->DB, i, &nameUTF16[0]); for (size_t c = 0; c < nameLength; ++c) { nameASCII[c] = static_cast(nameUTF16[c]); } + FixPathSeperator(&nameASCII[0]); - FString name = nameASCII; - FixPathSeperator(name); + FString name = &nameASCII[0]; name.ToLower(); lump_p->LumpNameSetup(name);