Commit 375c37c9 by Jamie Madill

ES3: Fix crash when binding nullptr to DEPTH_STENCIL.

In some cases, binding nullptr could query for the internal format of the null object, causing us to dereference null and crash. BUG=angleproject:1080 TEST=dEQP-GLES3.functional.multisample.fbo_* Change-Id: I592ab31dc1efadfac003c39051632fc2a0fff0cc Reviewed-on: https://chromium-review.googlesource.com/286853Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 86af3d27
......@@ -601,19 +601,21 @@ void Framebuffer::setAttachment(GLenum type,
if (binding == GL_DEPTH_STENCIL || binding == GL_DEPTH_STENCIL_ATTACHMENT)
{
// ensure this is a legitimate depth+stencil format
FramebufferAttachment::Target target(binding, textureIndex);
GLenum internalFormat = resource->getAttachmentInternalFormat(target);
const InternalFormat &formatInfo = GetInternalFormatInfo(internalFormat);
if (resource && formatInfo.depthBits > 0 && formatInfo.stencilBits > 0)
FramebufferAttachmentObject *attachmentObj = resource;
if (resource)
{
mData.mDepthAttachment.attach(type, binding, textureIndex, resource);
mData.mStencilAttachment.attach(type, binding, textureIndex, resource);
}
else
{
mData.mDepthAttachment.detach();
mData.mStencilAttachment.detach();
FramebufferAttachment::Target target(binding, textureIndex);
GLenum internalFormat = resource->getAttachmentInternalFormat(target);
const InternalFormat &formatInfo = GetInternalFormatInfo(internalFormat);
if (formatInfo.depthBits == 0 || formatInfo.stencilBits == 0)
{
// Attaching nullptr detaches the current attachment.
attachmentObj = nullptr;
}
}
mData.mDepthAttachment.attach(type, binding, textureIndex, attachmentObj);
mData.mStencilAttachment.attach(type, binding, textureIndex, attachmentObj);
mImpl->onUpdateDepthStencilAttachment();
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment