Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ahnyQuab ogg decompression crashes. #1507

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/Plasma/FeatureLib/pfPatcher/pfPatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ class pfPatcherStream : public plZlibStream
return retVal;
}

void Close()
dpogue marked this conversation as resolved.
Show resolved Hide resolved
{
if (hsCheckBits(fFlags, kFlagZipped))
plZlibStream::Close();
fOutput.reset();
}

uint32_t Write(uint32_t count, const void* buf) override
{
// tick whatever progress bar we have
Expand Down Expand Up @@ -383,6 +390,14 @@ static void IFileThingDownloadCB(ENetError result, void* param, const plFileName
pfPatcherWorker* patcher = static_cast<pfPatcherWorker*>(param);
pfPatcherStream* stream = static_cast<pfPatcherStream*>(writer);

// We need to explicitly close any underlying streams NOW because we
// might be about to signal the client that this file needs to be acted
// on, eg installed, decompressed from ogg to wave, etc. We can't wait
// for hsStream's RAII to close the stream at the end of this function or
// the callback code may crash due to either a permissions error or the
// zlib decompression not being complete.
stream->Close();

if (IS_NET_SUCCESS(result)) {
PatcherLogGreen("\tDownloaded File '{}'", stream->GetFileName());
patcher->WhitelistFile(stream->GetFileName(), true);
Expand Down