Bug 674042 - WebGL: crash in getUniformLocation with too long uniform identifiers - r=jrmuizel

This limits the length of uniform and attrib identifiers to 4095 characters, to steer clear GL implementation bugs with too long identifiers. The 4095 is totally arbitrary, all we know is that crashes happen after 2^22 chars.
This commit is contained in:
Benoit Jacob
2011-07-28 17:12:31 -04:00
parent 03041c7e2f
commit 5af7130aff
4 changed files with 20 additions and 1 deletions

View File

@@ -328,6 +328,17 @@ PRBool WebGLContext::ValidateDrawModeEnum(WebGLenum mode, const char *info)
}
}
bool WebGLContext::ValidateGLSLIdentifier(const nsAString& name, const char *info)
{
const PRUint32 maxSize = 4095;
if (name.Length() > maxSize) {
ErrorInvalidValue("%s: identifier is %d characters long, exceeds the maximum allowed length of %d characters",
info, name.Length(), maxSize);
return false;
}
return true;
}
PRUint32 WebGLContext::GetTexelSize(WebGLenum format, WebGLenum type)
{
if (type == LOCAL_GL_UNSIGNED_BYTE || type == LOCAL_GL_FLOAT) {