Bug 1320613 - Add nullptr check for attach. r=jgilbert,
authorvincentliu <vliu@mozilla.com>
Tue, 06 Dec 2016 14:34:39 -1000
changeset 325437 422dd1f29d6e8e8d05300e02849724e7d5d032f0
parent 325436 c65a9a96f48a5c3d7ac132df804cb829619a41b2
child 325438 991e29b1efd2495c5c8a35c98fed48643cd3e27f
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjgilbert
bugs1320613
milestone53.0a1
Bug 1320613 - Add nullptr check for attach. r=jgilbert, From 8f9578b8bebfdad04ca38eecd5fe0807b725e810 Mon Sep 17 00:00:00 2001 ethlin --- dom/canvas/WebGLFramebuffer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dom/canvas/WebGLFramebuffer.cpp
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -1283,17 +1283,17 @@ void
 WebGLFramebuffer::FramebufferRenderbuffer(const char* funcName, GLenum attachEnum,
                                           GLenum rbtarget, WebGLRenderbuffer* rb)
 {
     MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
                mContext->mBoundReadFramebuffer == this);
 
     // `attachment`
     const auto maybeAttach = GetAttachPoint(attachEnum);
-    if (!maybeAttach) {
+    if (!maybeAttach || !maybeAttach.value()) {
         mContext->ErrorInvalidEnum("%s: Bad `attachment`: 0x%x.", funcName, attachEnum);
         return;
     }
     const auto& attach = maybeAttach.value();
 
     // `rbTarget`
     if (rbtarget != LOCAL_GL_RENDERBUFFER) {
         mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: rbtarget:", rbtarget);
@@ -1321,17 +1321,17 @@ WebGLFramebuffer::FramebufferTexture2D(c
                                        GLenum texImageTarget, WebGLTexture* tex,
                                        GLint level)
 {
     MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
                mContext->mBoundReadFramebuffer == this);
 
     // `attachment`
     const auto maybeAttach = GetAttachPoint(attachEnum);
-    if (!maybeAttach) {
+    if (!maybeAttach || !maybeAttach.value()) {
         mContext->ErrorInvalidEnum("%s: Bad `attachment`: 0x%x.", funcName, attachEnum);
         return;
     }
     const auto& attach = maybeAttach.value();
 
     // `texImageTarget`
     if (texImageTarget != LOCAL_GL_TEXTURE_2D &&
         (texImageTarget < LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X ||
@@ -1408,17 +1408,17 @@ void
 WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnum,
                                           WebGLTexture* tex, GLint level, GLint layer)
 {
     MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
                mContext->mBoundReadFramebuffer == this);
 
     // `attachment`
     const auto maybeAttach = GetAttachPoint(attachEnum);
-    if (!maybeAttach) {
+    if (!maybeAttach || !maybeAttach.value()) {
         mContext->ErrorInvalidEnum("%s: Bad `attachment`: 0x%x.", funcName, attachEnum);
         return;
     }
     const auto& attach = maybeAttach.value();
 
     // `level`, `layer`
     if (layer < 0)
         return mContext->ErrorInvalidValue("%s: `layer` must be >= 0.", funcName);