Fix potential bad access in LinkProgram.
This could happen when linking a program with missing attachments
and shaders that have no compiled sources.
Also re-enables the EGL program cache control tests, which were
disabled due to a wrong extension name check.
Bug: chromium:827158
Change-Id: I181f878093c6e3a4acc51552ade8e7c084733a3d
Reviewed-on: https://chromium-review.googlesource.com/989262
Reviewed-by: Luc Ferron <lucferron@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp
index ee934e0..b1080d8 100644
--- a/src/libANGLE/Program.cpp
+++ b/src/libANGLE/Program.cpp
@@ -1049,9 +1049,16 @@
double startTime = platform->currentTime(platform);
unlink();
+ mInfoLog.reset();
+
+ // Validate we have properly attached shaders before checking the cache.
+ if (!linkValidateShaders(context, mInfoLog))
+ {
+ return NoError();
+ }
ProgramHash programHash;
- auto *cache = context->getMemoryProgramCache();
+ MemoryProgramCache *cache = context->getMemoryProgramCache();
if (cache)
{
ANGLE_TRY_RESULT(cache->getProgram(context, this, &mState, &programHash), mLinked);
@@ -1068,12 +1075,9 @@
// Cache load failed, fall through to normal linking.
unlink();
- mInfoLog.reset();
- if (!linkValidateShaders(context, mInfoLog))
- {
- return NoError();
- }
+ // Re-link shaders after the unlink call.
+ ASSERT(linkValidateShaders(context, mInfoLog));
if (mState.mAttachedComputeShader)
{
@@ -1284,6 +1288,7 @@
mValidated = false;
mLinked = false;
+ mInfoLog.reset();
}
bool Program::isLinked() const