Skip to content

Commit

Permalink
Fix crash when MSW shader entry is nullptr
Browse files Browse the repository at this point in the history
The shader entry can be a null if its simply not used by the game, or if it is a reference. We must correctly check on these correctly to avoid the program from crashing. Repak now adds these kinds of shaders correctly to the pak file.
  • Loading branch information
Mauler125 committed Dec 28, 2024
1 parent c1b654c commit 704a842
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/assets/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ static void Shader_CreateFromMSW(CPakFileBuilder* const pak, PakPageLump_s& cpuD

for (auto& it : shader->entries)
{
if (it.buffer != nullptr)
totalShaderDataSize += IALIGN(it.size, 8);
if (it.buffer == nullptr)
continue;

// If the shader type hasn't been found yet, parse this buffer and find out what we want to set it as.
if (hdr->type == eShaderType::Invalid)
Expand All @@ -33,6 +33,8 @@ static void Shader_CreateFromMSW(CPakFileBuilder* const pak, PakPageLump_s& cpuD
}
}
}

totalShaderDataSize += IALIGN(it.size, 8);
}
assert(totalShaderDataSize != 0);

Expand Down

0 comments on commit 704a842

Please sign in to comment.