<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214086] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214086">214086</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2017-03-16 17:51:02 -0700 (Thu, 16 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebGL: Improve index validation when using uint index values
https://bugs.webkit.org/show_bug.cgi?id=169798
Reviewed by Simon Fraser.
Source/WebCore:
Make sure that we test index validation with the correct type.
Also stop using -1 in WebGLBuffer to indicate non-existant values.
Test: fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html
* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::validateIndexArrayConservative): Use optional<> and
unsigned values.
* html/canvas/WebGLBuffer.cpp: Use unsigned for maxIndex (they can't be negative)
and optional<> to indicate unknown value.
(WebCore::WebGLBuffer::getCachedMaxIndex):
(WebCore::WebGLBuffer::setCachedMaxIndex):
* html/canvas/WebGLBuffer.h:
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateIndexArrayConservative): Use optional<> and
unsigned values.
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::validateVertexAttributes): No need to check if
an unsigned value is less than zero.
LayoutTests:
* fast/canvas/webgl/draw-elements-out-of-bounds-uint-index-expected.txt: Added.
* fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGL2RenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLBuffercpp">trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLBufferh">trunk/Source/WebCore/html/canvas/WebGLBuffer.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcanvaswebgldrawelementsoutofboundsuintindexexpectedtxt">trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvaswebgldrawelementsoutofboundsuintindexhtml">trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214085 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-17 00:51:01 UTC (rev 214085)
+++ trunk/LayoutTests/ChangeLog        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2017-03-16 Dean Jackson <dino@apple.com>
+
+ WebGL: Improve index validation when using uint index values
+ https://bugs.webkit.org/show_bug.cgi?id=169798
+
+ Reviewed by Simon Fraser.
+
+ * fast/canvas/webgl/draw-elements-out-of-bounds-uint-index-expected.txt: Added.
+ * fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html: Added.
+
</ins><span class="cx"> 2017-03-16 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><span class="cx"> Wrap legacy WebRTC API in runtime flag
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvaswebgldrawelementsoutofboundsuintindexexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index-expected.txt (0 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index-expected.txt        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test of drawElements with out-of-bounds parameters using OES_element_index_uint
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS context.drawElements(context.LINES, 1, context.UNSIGNED_INT, 0) generated expected GL error: INVALID_OPERATION.
+PASS context.drawElements(context.LINES, 1, context.UNSIGNED_INT, 0) generated expected GL error: INVALID_OPERATION.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/plain
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastcanvaswebgldrawelementsoutofboundsuintindexhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html (0 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html         (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="resources/webgl-test.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Test of drawElements with out-of-bounds parameters using OES_element_index_uint");
+
+if (window.internals)
+ window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
+
+var context = create3DContext();
+var program = loadStandardProgram(context);
+
+context.useProgram(program);
+context.getExtension("OES_element_index_uint");
+
+var buffer = context.createBuffer();
+context.bindBuffer(context.ARRAY_BUFFER, buffer);
+
+var data = new Uint8Array(0x100);
+context.bufferData(context.ARRAY_BUFFER, data, context.STATIC_DRAW);
+
+buffer = context.createBuffer();
+context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, buffer);
+
+data = new Uint32Array(new ArrayBuffer(0x10));
+data[0] = 0xffffffff;
+for (let i = 1; i < data.length; i++){
+ data[i] = 1;
+}
+context.bufferData(context.ELEMENT_ARRAY_BUFFER, data, context.STATIC_DRAW);
+
+context.enableVertexAttribArray(0);
+context.enableVertexAttribArray(1);
+context.vertexAttribPointer(0, 1, context.UNSIGNED_BYTE, false, 0, 0);
+context.vertexAttribPointer(1, 1, context.UNSIGNED_BYTE, false, 0, 0);
+
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.LINES, 1, context.UNSIGNED_INT, 0)");
+
+data[0] = 0xfffffffd;
+context.bufferData(context.ELEMENT_ARRAY_BUFFER, data, context.STATIC_DRAW);
+
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.LINES, 1, context.UNSIGNED_INT, 0)");
+</script>
+</body>
+</html>
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214085 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-17 00:51:01 UTC (rev 214085)
+++ trunk/Source/WebCore/ChangeLog        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2017-03-16 Dean Jackson <dino@apple.com>
+
+ WebGL: Improve index validation when using uint index values
+ https://bugs.webkit.org/show_bug.cgi?id=169798
+
+ Reviewed by Simon Fraser.
+
+ Make sure that we test index validation with the correct type.
+ Also stop using -1 in WebGLBuffer to indicate non-existant values.
+
+ Test: fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html
+
+ * html/canvas/WebGL2RenderingContext.cpp:
+ (WebCore::WebGL2RenderingContext::validateIndexArrayConservative): Use optional<> and
+ unsigned values.
+ * html/canvas/WebGLBuffer.cpp: Use unsigned for maxIndex (they can't be negative)
+ and optional<> to indicate unknown value.
+ (WebCore::WebGLBuffer::getCachedMaxIndex):
+ (WebCore::WebGLBuffer::setCachedMaxIndex):
+ * html/canvas/WebGLBuffer.h:
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::validateIndexArrayConservative): Use optional<> and
+ unsigned values.
+ * html/canvas/WebGLRenderingContextBase.cpp:
+ (WebCore::WebGLRenderingContextBase::validateVertexAttributes): No need to check if
+ an unsigned value is less than zero.
+
</ins><span class="cx"> 2017-03-16 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Improve the system tracing points
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGL2RenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (214085 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp        2017-03-17 00:51:01 UTC (rev 214085)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -1748,14 +1748,14 @@
</span><span class="cx"> auto* buffer = elementArrayBuffer->elementArrayBuffer();
</span><span class="cx"> ASSERT(buffer);
</span><span class="cx">
</span><del>- int maxIndex = elementArrayBuffer->getCachedMaxIndex(type);
- if (maxIndex < 0) {
</del><ins>+ std::optional<unsigned> maxIndex = elementArrayBuffer->getCachedMaxIndex(type);
+ if (!maxIndex) {
</ins><span class="cx"> // Compute the maximum index in the entire buffer for the given type of index.
</span><span class="cx"> switch (type) {
</span><span class="cx"> case GraphicsContext3D::UNSIGNED_BYTE: {
</span><span class="cx"> const GC3Dubyte* p = static_cast<const GC3Dubyte*>(buffer->data());
</span><span class="cx"> for (GC3Dsizeiptr i = 0; i < numElements; i++)
</span><del>- maxIndex = std::max(maxIndex, static_cast<int>(p[i]));
</del><ins>+ maxIndex = maxIndex ? std::max(maxIndex.value(), static_cast<unsigned>(p[i])) : static_cast<unsigned>(p[i]);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case GraphicsContext3D::UNSIGNED_SHORT: {
</span><span class="lines">@@ -1762,7 +1762,7 @@
</span><span class="cx"> numElements /= sizeof(GC3Dushort);
</span><span class="cx"> const GC3Dushort* p = static_cast<const GC3Dushort*>(buffer->data());
</span><span class="cx"> for (GC3Dsizeiptr i = 0; i < numElements; i++)
</span><del>- maxIndex = std::max(maxIndex, static_cast<int>(p[i]));
</del><ins>+ maxIndex = maxIndex ? std::max(maxIndex.value(), static_cast<unsigned>(p[i])) : static_cast<unsigned>(p[i]);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case GraphicsContext3D::UNSIGNED_INT: {
</span><span class="lines">@@ -1769,23 +1769,25 @@
</span><span class="cx"> numElements /= sizeof(GC3Duint);
</span><span class="cx"> const GC3Duint* p = static_cast<const GC3Duint*>(buffer->data());
</span><span class="cx"> for (GC3Dsizeiptr i = 0; i < numElements; i++)
</span><del>- maxIndex = std::max(maxIndex, static_cast<int>(p[i]));
</del><ins>+ maxIndex = maxIndex ? std::max(maxIndex.value(), static_cast<unsigned>(p[i])) : static_cast<unsigned>(p[i]);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> default:
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><del>- elementArrayBuffer->setCachedMaxIndex(type, maxIndex);
</del><ins>+ if (maxIndex)
+ elementArrayBuffer->setCachedMaxIndex(type, maxIndex.value());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- if (maxIndex >= 0) {
- // The number of required elements is one more than the maximum
- // index that will be accessed.
- numElementsRequired = maxIndex + 1;
- return true;
- }
-
- return false;
</del><ins>+ if (!maxIndex)
+ return false;
+
+ // The number of required elements is one more than the maximum
+ // index that will be accessed.
+ numElementsRequired = maxIndex.value() + 1;
+
+ // Check for overflow.
+ return numElementsRequired > 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool WebGL2RenderingContext::validateBlendEquation(const char* functionName, GC3Denum mode)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp (214085 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp        2017-03-17 00:51:01 UTC (rev 214085)
+++ trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -228,16 +228,16 @@
</span><span class="cx"> return m_byteLength;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-int WebGLBuffer::getCachedMaxIndex(GC3Denum type)
</del><ins>+std::optional<unsigned> WebGLBuffer::getCachedMaxIndex(GC3Denum type)
</ins><span class="cx"> {
</span><span class="cx"> for (auto& cache : m_maxIndexCache) {
</span><span class="cx"> if (cache.type == type)
</span><span class="cx"> return cache.maxIndex;
</span><span class="cx"> }
</span><del>- return -1;
</del><ins>+ return std::nullopt;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebGLBuffer::setCachedMaxIndex(GC3Denum type, int value)
</del><ins>+void WebGLBuffer::setCachedMaxIndex(GC3Denum type, unsigned value)
</ins><span class="cx"> {
</span><span class="cx"> for (auto& cache : m_maxIndexCache) {
</span><span class="cx"> if (cache.type == type) {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLBuffer.h (214085 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLBuffer.h        2017-03-17 00:51:01 UTC (rev 214085)
+++ trunk/Source/WebCore/html/canvas/WebGLBuffer.h        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -52,11 +52,10 @@
</span><span class="cx"> GC3Dsizeiptr byteLength() const;
</span><span class="cx"> const JSC::ArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); }
</span><span class="cx">
</span><del>- // Gets the cached max index for the given type. Returns -1 if
- // none has been set.
- int getCachedMaxIndex(GC3Denum type);
</del><ins>+ // Gets the cached max index for the given type if one has been set.
+ std::optional<unsigned> getCachedMaxIndex(GC3Denum type);
</ins><span class="cx"> // Sets the cached max index for the given type.
</span><del>- void setCachedMaxIndex(GC3Denum type, int value);
</del><ins>+ void setCachedMaxIndex(GC3Denum type, unsigned value);
</ins><span class="cx">
</span><span class="cx"> GC3Denum getTarget() const { return m_target; }
</span><span class="cx"> void setTarget(GC3Denum, bool forWebGL2);
</span><span class="lines">@@ -83,11 +82,10 @@
</span><span class="cx"> // that size.
</span><span class="cx"> struct MaxIndexCacheEntry {
</span><span class="cx"> GC3Denum type;
</span><del>- int maxIndex;
</del><ins>+ unsigned maxIndex;
</ins><span class="cx"> };
</span><span class="cx"> // OpenGL ES 2.0 only has two valid index types (UNSIGNED_BYTE
</span><del>- // and UNSIGNED_SHORT), but might as well leave open the
- // possibility of adding others.
</del><ins>+ // and UNSIGNED_SHORT) plus one extension (UNSIGNED_INT).
</ins><span class="cx"> MaxIndexCacheEntry m_maxIndexCache[4];
</span><span class="cx"> unsigned m_nextAvailableCacheEntry { 0 };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (214085 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2017-03-17 00:51:01 UTC (rev 214085)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -754,14 +754,14 @@
</span><span class="cx"> const ArrayBuffer* buffer = elementArrayBuffer->elementArrayBuffer();
</span><span class="cx"> ASSERT(buffer);
</span><span class="cx">
</span><del>- int maxIndex = elementArrayBuffer->getCachedMaxIndex(type);
- if (maxIndex < 0) {
</del><ins>+ std::optional<unsigned> maxIndex = elementArrayBuffer->getCachedMaxIndex(type);
+ if (!maxIndex) {
</ins><span class="cx"> // Compute the maximum index in the entire buffer for the given type of index.
</span><span class="cx"> switch (type) {
</span><span class="cx"> case GraphicsContext3D::UNSIGNED_BYTE: {
</span><span class="cx"> const GC3Dubyte* p = static_cast<const GC3Dubyte*>(buffer->data());
</span><span class="cx"> for (GC3Dsizeiptr i = 0; i < numElements; i++)
</span><del>- maxIndex = std::max(maxIndex, static_cast<int>(p[i]));
</del><ins>+ maxIndex = maxIndex ? std::max(maxIndex.value(), static_cast<unsigned>(p[i])) : static_cast<unsigned>(p[i]);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case GraphicsContext3D::UNSIGNED_SHORT: {
</span><span class="lines">@@ -768,7 +768,7 @@
</span><span class="cx"> numElements /= sizeof(GC3Dushort);
</span><span class="cx"> const GC3Dushort* p = static_cast<const GC3Dushort*>(buffer->data());
</span><span class="cx"> for (GC3Dsizeiptr i = 0; i < numElements; i++)
</span><del>- maxIndex = std::max(maxIndex, static_cast<int>(p[i]));
</del><ins>+ maxIndex = maxIndex ? std::max(maxIndex.value(), static_cast<unsigned>(p[i])) : static_cast<unsigned>(p[i]);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case GraphicsContext3D::UNSIGNED_INT: {
</span><span class="lines">@@ -777,23 +777,25 @@
</span><span class="cx"> numElements /= sizeof(GC3Duint);
</span><span class="cx"> const GC3Duint* p = static_cast<const GC3Duint*>(buffer->data());
</span><span class="cx"> for (GC3Dsizeiptr i = 0; i < numElements; i++)
</span><del>- maxIndex = std::max(maxIndex, static_cast<int>(p[i]));
</del><ins>+ maxIndex = maxIndex ? std::max(maxIndex.value(), static_cast<unsigned>(p[i])) : static_cast<unsigned>(p[i]);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> default:
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><del>- elementArrayBuffer->setCachedMaxIndex(type, maxIndex);
</del><ins>+ if (maxIndex)
+ elementArrayBuffer->setCachedMaxIndex(type, maxIndex.value());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- if (maxIndex >= 0) {
- // The number of required elements is one more than the maximum
- // index that will be accessed.
- numElementsRequired = maxIndex + 1;
- return true;
- }
-
- return false;
</del><ins>+ if (!maxIndex)
+ return false;
+
+ // The number of required elements is one more than the maximum
+ // index that will be accessed.
+ numElementsRequired = maxIndex.value() + 1;
+
+ // Check for overflow.
+ return numElementsRequired > 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool WebGLRenderingContext::validateBlendEquation(const char* functionName, GC3Denum mode)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (214085 => 214086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2017-03-17 00:51:01 UTC (rev 214085)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2017-03-17 00:51:02 UTC (rev 214086)
</span><span class="lines">@@ -1781,7 +1781,7 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (elementCount <= 0)
</del><ins>+ if (!elementCount)
</ins><span class="cx"> return true;
</span><span class="cx">
</span><span class="cx"> // Look in each consumed vertex attrib (by the current program).
</span></span></pre>
</div>
</div>
</body>
</html>