OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1618 | 1618 |
1619 void WebGLRenderingContextBase::bufferSubDataImpl(GLenum target, long long offse t, GLsizeiptr size, const void* data) | 1619 void WebGLRenderingContextBase::bufferSubDataImpl(GLenum target, long long offse t, GLsizeiptr size, const void* data) |
1620 { | 1620 { |
1621 WebGLBuffer* buffer = validateBufferDataTarget("bufferSubData", target); | 1621 WebGLBuffer* buffer = validateBufferDataTarget("bufferSubData", target); |
1622 if (!buffer) | 1622 if (!buffer) |
1623 return; | 1623 return; |
1624 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset)) | 1624 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset)) |
1625 return; | 1625 return; |
1626 if (!data) | 1626 if (!data) |
1627 return; | 1627 return; |
1628 if (offset + static_cast<long long>(size) > buffer->getSize()) { | |
1629 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "buffer overflow"); | |
1630 return; | |
1631 } | |
1628 | 1632 |
1629 webContext()->bufferSubData(target, static_cast<GLintptr>(offset), size, dat a); | 1633 webContext()->bufferSubData(target, static_cast<GLintptr>(offset), size, dat a); |
1630 } | 1634 } |
1631 | 1635 |
1632 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, D OMArrayBuffer* data) | 1636 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, D OMArrayBuffer* data) |
1633 { | 1637 { |
1634 if (isContextLost()) | 1638 if (isContextLost()) |
1635 return; | 1639 return; |
1636 if (!data) | 1640 if (!data) |
1637 return; | 1641 return; |
(...skipping 4233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5871 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 5875 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
5872 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 5876 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
5873 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 5877 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
5874 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 5878 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { |
5875 const int kBlockWidth = 4; | 5879 const int kBlockWidth = 4; |
5876 const int kBlockHeight = 4; | 5880 const int kBlockHeight = 4; |
5877 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | 5881 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { |
5878 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset not multiple of 4"); | 5882 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset not multiple of 4"); |
5879 return false; | 5883 return false; |
5880 } | 5884 } |
5881 if (width - xoffset > tex->getWidth(target, level) | 5885 if (width + xoffset > tex->getWidth(target, level) |
Zhenyao Mo
2015/09/02 17:59:03
You need to do overflow test here. See Checked<>
yunchao
2015/09/04 08:22:07
Done.
| |
5882 || height - yoffset > tex->getHeight(target, level)) { | 5886 || height + yoffset > tex->getHeight(target, level)) { |
5883 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions ou t of range"); | 5887 synthesizeGLError(GL_INVALID_VALUE, functionName, "dimensions out of range"); |
5884 return false; | 5888 return false; |
5885 } | 5889 } |
5886 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); | 5890 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); |
5887 } | 5891 } |
5888 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | 5892 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: |
5889 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | 5893 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: |
5890 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | 5894 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: |
5891 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | 5895 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { |
5892 if ((xoffset != 0) || (yoffset != 0)) { | 5896 if ((xoffset != 0) || (yoffset != 0)) { |
5893 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset and y offset must be zero"); | 5897 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset and y offset must be zero"); |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6702 | 6706 |
6703 return totalBytesPerPixel; | 6707 return totalBytesPerPixel; |
6704 } | 6708 } |
6705 | 6709 |
6706 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6710 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6707 { | 6711 { |
6708 return m_drawingBuffer.get(); | 6712 return m_drawingBuffer.get(); |
6709 } | 6713 } |
6710 | 6714 |
6711 } // namespace blink | 6715 } // namespace blink |
OLD | NEW |