Skip to content

Commit

Permalink
Fix possible crash when loading GL shader caches. Should help #9930.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Aug 25, 2017
1 parent 2180b1d commit 4938ab7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions GPU/GLES/ShaderManagerGLES.cpp
Expand Up @@ -1023,15 +1023,23 @@ void ShaderManagerGLES::LoadAndPrecompile(const std::string &filename) {
delete vs;
return;
}
vsCache_.Insert(id, vs);
if (!vsCache_.Get(id)) {
vsCache_.Insert(id, vs);
} else {
WARN_LOG(G3D, "Duplicate vertex shader found in GL shader cache, ignoring");
}
}
for (int i = 0; i < header.numFragmentShaders; i++) {
ShaderID id;
if (!f.ReadArray(&id, 1)) {
ERROR_LOG(G3D, "Truncated shader cache file, aborting.");
return;
}
fsCache_.Insert(id, CompileFragmentShader(id));
if (!fsCache_.Get(id)) {
fsCache_.Insert(id, CompileFragmentShader(id));
} else {
WARN_LOG(G3D, "Duplicate fragment shader found in GL shader cache, ignoring");
}
}
for (int i = 0; i < header.numLinkedPrograms; i++) {
ShaderID vsid, fsid;
Expand Down

0 comments on commit 4938ab7

Please sign in to comment.