Title: [110485] trunk
Revision
110485
Author
[email protected]
Date
2012-03-12 14:59:15 -0700 (Mon, 12 Mar 2012)

Log Message

Null argument to texSubImage2D crashes
https://bugs.webkit.org/show_bug.cgi?id=80778

Reviewed by Dean Jackson.

Source/WebCore:

Generate INVALID_VALUE OpenGL error upon receiving null argument.
Final behavior still being decided on public-webgl mailing list.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::texSubImage2D):
(WebCore::WebGLRenderingContext::validateTexFuncData):
* html/canvas/WebGLRenderingContext.h:

LayoutTests:

Updated tex-sub-image-2d-bad-args test to verify new behavior.

* fast/canvas/webgl/tex-sub-image-2d-bad-args-expected.txt:
* fast/canvas/webgl/tex-sub-image-2d-bad-args.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110484 => 110485)


--- trunk/LayoutTests/ChangeLog	2012-03-12 21:54:35 UTC (rev 110484)
+++ trunk/LayoutTests/ChangeLog	2012-03-12 21:59:15 UTC (rev 110485)
@@ -1,3 +1,15 @@
+2012-03-12  Kenneth Russell  <[email protected]>
+
+        Null argument to texSubImage2D crashes
+        https://bugs.webkit.org/show_bug.cgi?id=80778
+
+        Reviewed by Dean Jackson.
+
+        Updated tex-sub-image-2d-bad-args test to verify new behavior.
+
+        * fast/canvas/webgl/tex-sub-image-2d-bad-args-expected.txt:
+        * fast/canvas/webgl/tex-sub-image-2d-bad-args.html:
+
 2012-03-12  Dimitri Glazkov  <[email protected]>
 
         4 shadow DOM tests fail on Mac port

Modified: trunk/LayoutTests/fast/canvas/webgl/tex-sub-image-2d-bad-args-expected.txt (110484 => 110485)


--- trunk/LayoutTests/fast/canvas/webgl/tex-sub-image-2d-bad-args-expected.txt	2012-03-12 21:54:35 UTC (rev 110484)
+++ trunk/LayoutTests/fast/canvas/webgl/tex-sub-image-2d-bad-args-expected.txt	2012-03-12 21:59:15 UTC (rev 110485)
@@ -4,6 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 PASS getError was expected value: NO_ERROR : Setup should succeed
+PASS getError was expected value: INVALID_VALUE : null argument
 PASS getError was expected value: INVALID_VALUE : y + height > texture height
 PASS getError was expected value: INVALID_VALUE : x + width > texture width
 PASS getError was expected value: INVALID_VALUE : negative x

Modified: trunk/LayoutTests/fast/canvas/webgl/tex-sub-image-2d-bad-args.html (110484 => 110485)


--- trunk/LayoutTests/fast/canvas/webgl/tex-sub-image-2d-bad-args.html	2012-03-12 21:54:35 UTC (rev 110484)
+++ trunk/LayoutTests/fast/canvas/webgl/tex-sub-image-2d-bad-args.html	2012-03-12 21:59:15 UTC (rev 110485)
@@ -22,6 +22,10 @@
 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c);
 glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed"); 
 
+// FIXME: this behavior is still being discussed on the public_webgl mailing list and may
+// need to be changed to throw TypeError because the argument is not nullable.
+gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, null);
+glErrorShouldBe(gl, gl.INVALID_VALUE, "null argument");
 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 1, gl.RGBA, gl.UNSIGNED_BYTE, c);
 glErrorShouldBe(gl, gl.INVALID_VALUE, "y + height > texture height");
 gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);

Modified: trunk/Source/WebCore/ChangeLog (110484 => 110485)


--- trunk/Source/WebCore/ChangeLog	2012-03-12 21:54:35 UTC (rev 110484)
+++ trunk/Source/WebCore/ChangeLog	2012-03-12 21:59:15 UTC (rev 110485)
@@ -1,3 +1,20 @@
+2012-03-12  Kenneth Russell  <[email protected]>
+
+        Null argument to texSubImage2D crashes
+        https://bugs.webkit.org/show_bug.cgi?id=80778
+
+        Reviewed by Dean Jackson.
+
+        Generate INVALID_VALUE OpenGL error upon receiving null argument.
+        Final behavior still being decided on public-webgl mailing list.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore):
+        (WebCore::WebGLRenderingContext::texImage2D):
+        (WebCore::WebGLRenderingContext::texSubImage2D):
+        (WebCore::WebGLRenderingContext::validateTexFuncData):
+        * html/canvas/WebGLRenderingContext.h:
+
 2012-03-12  Luke Macpherson   <[email protected]>
 
         Remove CSSStyleSelector's convertToLength method and use CSSPrimitiveValue's version directly.

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (110484 => 110485)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-03-12 21:54:35 UTC (rev 110484)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-03-12 21:59:15 UTC (rev 110485)
@@ -3426,7 +3426,7 @@
                                        GC3Dsizei width, GC3Dsizei height, GC3Dint border,
                                        GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec)
 {
-    if (isContextLost() || !validateTexFuncData("texImage2D", width, height, format, type, pixels))
+    if (isContextLost() || !validateTexFuncData("texImage2D", width, height, format, type, pixels, NullAllowed))
         return;
     void* data = "" ? pixels->baseAddress() : 0;
     Vector<uint8_t> tempData;
@@ -3639,9 +3639,9 @@
                                           GC3Dsizei width, GC3Dsizei height,
                                           GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec)
 {
-    if (isContextLost() || !validateTexFuncData("texSubImage2D", width, height, format, type, pixels))
+    if (isContextLost() || !validateTexFuncData("texSubImage2D", width, height, format, type, pixels, NullNotAllowed))
         return;
-    void* data = "" ? pixels->baseAddress() : 0;
+    void* data = ""
     Vector<uint8_t> tempData;
     bool changeUnpackAlignment = false;
     if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
@@ -4715,10 +4715,15 @@
 bool WebGLRenderingContext::validateTexFuncData(const char* functionName,
                                                 GC3Dsizei width, GC3Dsizei height,
                                                 GC3Denum format, GC3Denum type,
-                                                ArrayBufferView* pixels)
+                                                ArrayBufferView* pixels,
+                                                NullDisposition disposition)
 {
-    if (!pixels)
-        return true;
+    if (!pixels) {
+        if (disposition == NullAllowed)
+            return true;
+        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pixels");
+        return false;
+    }
 
     if (!validateTexFuncFormatAndType(functionName, format, type))
         return false;

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (110484 => 110485)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2012-03-12 21:54:35 UTC (rev 110484)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2012-03-12 21:59:15 UTC (rev 110485)
@@ -587,13 +587,19 @@
                                    GC3Dsizei width, GC3Dsizei height, GC3Dint border,
                                    GC3Denum format, GC3Denum type);
 
+    enum NullDisposition {
+        NullAllowed,
+        NullNotAllowed
+    };
+
     // Helper function to validate that the given ArrayBufferView
     // is of the correct type and contains enough data for the texImage call.
     // Generates GL error and returns false if parameters are invalid.
     bool validateTexFuncData(const char* functionName,
                              GC3Dsizei width, GC3Dsizei height,
                              GC3Denum format, GC3Denum type,
-                             ArrayBufferView* pixels);
+                             ArrayBufferView* pixels,
+                             NullDisposition);
 
     // Helper function to validate compressed texture data is correct size
     // for the given format and dimensions.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to