From ab17e42ca2e3427fb862d7009a9650b739d6dd82 Mon Sep 17 00:00:00 2001 From: Konstantin Timoshenko Date: Tue, 14 Nov 2023 20:46:51 +0300 Subject: [PATCH 1/5] Update WebGLAttributes.js Strict check for buffer size while upload.. --- src/renderers/webgl/WebGLAttributes.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderers/webgl/WebGLAttributes.js b/src/renderers/webgl/WebGLAttributes.js index 6ff4e6ebad277d..e0461bf57952dd 100644 --- a/src/renderers/webgl/WebGLAttributes.js +++ b/src/renderers/webgl/WebGLAttributes.js @@ -8,6 +8,7 @@ function WebGLAttributes( gl, capabilities ) { const array = attribute.array; const usage = attribute.usage; + const size = array.byteLength; const buffer = gl.createBuffer(); @@ -76,7 +77,8 @@ function WebGLAttributes( gl, capabilities ) { buffer: buffer, type: type, bytesPerElement: array.BYTES_PER_ELEMENT, - version: attribute.version + version: attribute.version, + size: size }; } @@ -199,6 +201,10 @@ function WebGLAttributes( gl, capabilities ) { } else if ( data.version < attribute.version ) { + if ( data.size < attribute.array.byteLength ) { + throw new Error( 'Too many data for update current attribute, dynamic sized attributes not supported.' ); + } + updateBuffer( data.buffer, attribute, bufferType ); data.version = attribute.version; From fbd381a09a7ed4fbd48083dfc473eea44dad7f78 Mon Sep 17 00:00:00 2001 From: Konstantin Timoshenko Date: Tue, 14 Nov 2023 20:51:40 +0300 Subject: [PATCH 2/5] fix: lint, pads --- src/renderers/webgl/WebGLAttributes.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderers/webgl/WebGLAttributes.js b/src/renderers/webgl/WebGLAttributes.js index e0461bf57952dd..f53832bf1c49f2 100644 --- a/src/renderers/webgl/WebGLAttributes.js +++ b/src/renderers/webgl/WebGLAttributes.js @@ -202,7 +202,9 @@ function WebGLAttributes( gl, capabilities ) { } else if ( data.version < attribute.version ) { if ( data.size < attribute.array.byteLength ) { + throw new Error( 'Too many data for update current attribute, dynamic sized attributes not supported.' ); + } updateBuffer( data.buffer, attribute, bufferType ); From 9c741439d9f1ce38f3ec8a2cad0e09d90d66f2b4 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Thu, 16 Nov 2023 11:10:42 +0100 Subject: [PATCH 3/5] Update WebGLAttributes.js Implement the check even more strict. Clarify error message. --- src/renderers/webgl/WebGLAttributes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderers/webgl/WebGLAttributes.js b/src/renderers/webgl/WebGLAttributes.js index f53832bf1c49f2..84c83fb6c36f65 100644 --- a/src/renderers/webgl/WebGLAttributes.js +++ b/src/renderers/webgl/WebGLAttributes.js @@ -201,9 +201,9 @@ function WebGLAttributes( gl, capabilities ) { } else if ( data.version < attribute.version ) { - if ( data.size < attribute.array.byteLength ) { + if ( data.size !== attribute.array.byteLength ) { - throw new Error( 'Too many data for update current attribute, dynamic sized attributes not supported.' ); + throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Dynamic sized attributes not supported.' ); } From 6ca20518e6f737084c1aab1178d2ce9812bf9b9d Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Thu, 16 Nov 2023 17:48:44 +0100 Subject: [PATCH 4/5] Update WebGLAttributes.js --- src/renderers/webgl/WebGLAttributes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderers/webgl/WebGLAttributes.js b/src/renderers/webgl/WebGLAttributes.js index 84c83fb6c36f65..c1c681c3ba985a 100644 --- a/src/renderers/webgl/WebGLAttributes.js +++ b/src/renderers/webgl/WebGLAttributes.js @@ -203,7 +203,7 @@ function WebGLAttributes( gl, capabilities ) { if ( data.size !== attribute.array.byteLength ) { - throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Dynamic sized attributes not supported.' ); + throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Resizing buffer attributes is supported.' ); } From a25c8f9e51a895c2ec9c4f6cf4c65cb1839f46e0 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Thu, 16 Nov 2023 17:49:49 +0100 Subject: [PATCH 5/5] Update WebGLAttributes.js Fix typo. --- src/renderers/webgl/WebGLAttributes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderers/webgl/WebGLAttributes.js b/src/renderers/webgl/WebGLAttributes.js index c1c681c3ba985a..fc52e617448d6f 100644 --- a/src/renderers/webgl/WebGLAttributes.js +++ b/src/renderers/webgl/WebGLAttributes.js @@ -203,7 +203,7 @@ function WebGLAttributes( gl, capabilities ) { if ( data.size !== attribute.array.byteLength ) { - throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Resizing buffer attributes is supported.' ); + throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Resizing buffer attributes is not supported.' ); }