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, ...@@ -601,19 +601,21 @@ void Framebuffer::setAttachment(GLenum type,
if (binding == GL_DEPTH_STENCIL || binding == GL_DEPTH_STENCIL_ATTACHMENT) if (binding == GL_DEPTH_STENCIL || binding == GL_DEPTH_STENCIL_ATTACHMENT)
{ {
// ensure this is a legitimate depth+stencil format // ensure this is a legitimate depth+stencil format
FramebufferAttachment::Target target(binding, textureIndex); FramebufferAttachmentObject *attachmentObj = resource;
GLenum internalFormat = resource->getAttachmentInternalFormat(target); if (resource)
const InternalFormat &formatInfo = GetInternalFormatInfo(internalFormat);
if (resource && formatInfo.depthBits > 0 && formatInfo.stencilBits > 0)
{ {
mData.mDepthAttachment.attach(type, binding, textureIndex, resource); FramebufferAttachment::Target target(binding, textureIndex);
mData.mStencilAttachment.attach(type, binding, textureIndex, resource); GLenum internalFormat = resource->getAttachmentInternalFormat(target);
} const InternalFormat &formatInfo = GetInternalFormatInfo(internalFormat);
else if (formatInfo.depthBits == 0 || formatInfo.stencilBits == 0)
{ {
mData.mDepthAttachment.detach(); // Attaching nullptr detaches the current attachment.
mData.mStencilAttachment.detach(); attachmentObj = nullptr;
}
} }
mData.mDepthAttachment.attach(type, binding, textureIndex, attachmentObj);
mData.mStencilAttachment.attach(type, binding, textureIndex, attachmentObj);
mImpl->onUpdateDepthStencilAttachment(); mImpl->onUpdateDepthStencilAttachment();
} }
else 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