mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- 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:
parent
2223c12938
commit
ea7fb936a8
1 changed files with 7 additions and 9 deletions
|
@ -264,6 +264,8 @@ bool F7ZFile::Open(bool quiet)
|
||||||
Lumps = new F7ZLump[NumLumps];
|
Lumps = new F7ZLump[NumLumps];
|
||||||
|
|
||||||
F7ZLump *lump_p = Lumps;
|
F7ZLump *lump_p = Lumps;
|
||||||
|
TArray<UInt16> nameUTF16;
|
||||||
|
TArray<char> nameASCII;
|
||||||
for (DWORD i = 0; i < NumLumps; ++i)
|
for (DWORD i = 0; i < NumLumps; ++i)
|
||||||
{
|
{
|
||||||
CSzFileItem *file = &Archive->DB.db.Files[i];
|
CSzFileItem *file = &Archive->DB.db.Files[i];
|
||||||
|
@ -283,20 +285,16 @@ bool F7ZFile::Open(bool quiet)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert UTF-16 filename to plain ASCII
|
nameUTF16.Resize(nameLength);
|
||||||
|
nameASCII.Resize(nameLength);
|
||||||
UInt16* const nameUTF16 = static_cast<UInt16*>(alloca(sizeof(UInt16) * nameLength));
|
SzArEx_GetFileNameUtf16(&Archive->DB, i, &nameUTF16[0]);
|
||||||
SzArEx_GetFileNameUtf16(&Archive->DB, i, nameUTF16);
|
|
||||||
|
|
||||||
char* const nameASCII = static_cast<char*>(alloca(nameLength));
|
|
||||||
|
|
||||||
for (size_t c = 0; c < nameLength; ++c)
|
for (size_t c = 0; c < nameLength; ++c)
|
||||||
{
|
{
|
||||||
nameASCII[c] = static_cast<char>(nameUTF16[c]);
|
nameASCII[c] = static_cast<char>(nameUTF16[c]);
|
||||||
}
|
}
|
||||||
|
FixPathSeperator(&nameASCII[0]);
|
||||||
|
|
||||||
FString name = nameASCII;
|
FString name = &nameASCII[0];
|
||||||
FixPathSeperator(name);
|
|
||||||
name.ToLower();
|
name.ToLower();
|
||||||
|
|
||||||
lump_p->LumpNameSetup(name);
|
lump_p->LumpNameSetup(name);
|
||||||
|
|
Loading…
Reference in a new issue