diff --git a/src/resourcefiles/file_7z.cpp b/src/resourcefiles/file_7z.cpp index a7d173a4e61..53653bb59e8 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);