- fixed: memory allocation for file names in 7z archives was broken. Changing it to use TArray instead of alloca makes it work.

This commit is contained in:
Christoph Oelckers 2014-05-08 10:33:32 +02:00
parent 2223c12938
commit ea7fb936a8
1 changed files with 7 additions and 9 deletions

View File

@ -264,6 +264,8 @@ bool F7ZFile::Open(bool quiet)
Lumps = new F7ZLump[NumLumps];
F7ZLump *lump_p = Lumps;
TArray<UInt16> nameUTF16;
TArray<char> 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<UInt16*>(alloca(sizeof(UInt16) * nameLength));
SzArEx_GetFileNameUtf16(&Archive->DB, i, nameUTF16);
char* const nameASCII = static_cast<char*>(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<char>(nameUTF16[c]);
}
FixPathSeperator(&nameASCII[0]);
FString name = nameASCII;
FixPathSeperator(name);
FString name = &nameASCII[0];
name.ToLower();
lump_p->LumpNameSetup(name);