Bug 791905 - reject WebGL canvas sizes greater than INT_MAX - r=jgilbert

This commit is contained in:
Benoit Jacob 2012-09-27 10:13:45 -04:00
parent eb01982a02
commit 26ad5de498

View File

@ -329,11 +329,18 @@ WebGLContext::SetContextOptions(nsIPropertyBag *aOptions)
NS_IMETHODIMP
WebGLContext::SetDimensions(int32_t width, int32_t height)
{
/*** early success return cases ***/
// Early error return cases
if (width < 0 || height < 0) {
GenerateWarning("Canvas size is too large (seems like a negative value wrapped)");
return NS_ERROR_OUT_OF_MEMORY;
}
if (!GetCanvas())
return NS_ERROR_FAILURE;
// Early success return cases
GetCanvas()->InvalidateCanvas();
if (gl && mWidth == width && mHeight == height)
@ -362,10 +369,9 @@ WebGLContext::SetDimensions(int32_t width, int32_t height)
return NS_OK;
}
/*** End of early success return cases.
*** At this point we know that we're not just resizing an existing context,
*** we are initializing a new context.
***/
// End of early return cases.
// At this point we know that we're not just resizing an existing context,
// we are initializing a new context.
// if we exceeded either the global or the per-principal limit for WebGL contexts,
// lose the oldest-used context now to free resources. Note that we can't do that