Commit 416a23e8 by Geoff Lang Committed by Commit Bot

ProgramGL: Make sure the binary vector does not read out of bounds.

By sizing the vector to at least one element, it is not possible to pass invalid pointers to the driver or binary stream even if the binary is zero-sized. BUG=angleproject:2257 Change-Id: Ie0e42bff1192207e0e069934b03dfd49e8d34824 Reviewed-on: https://chromium-review.googlesource.com/779739Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 4dd167fb
...@@ -83,14 +83,14 @@ void ProgramGL::save(const gl::Context *context, gl::BinaryOutputStream *stream) ...@@ -83,14 +83,14 @@ void ProgramGL::save(const gl::Context *context, gl::BinaryOutputStream *stream)
GLint binaryLength = 0; GLint binaryLength = 0;
mFunctions->getProgramiv(mProgramID, GL_PROGRAM_BINARY_LENGTH, &binaryLength); mFunctions->getProgramiv(mProgramID, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
std::vector<uint8_t> binary(binaryLength); std::vector<uint8_t> binary(std::max(binaryLength, 1));
GLenum binaryFormat = GL_NONE; GLenum binaryFormat = GL_NONE;
mFunctions->getProgramBinary(mProgramID, binaryLength, &binaryLength, &binaryFormat, mFunctions->getProgramBinary(mProgramID, binaryLength, &binaryLength, &binaryFormat,
&binary[0]); binary.data());
stream->writeInt(binaryFormat); stream->writeInt(binaryFormat);
stream->writeInt(binaryLength); stream->writeInt(binaryLength);
stream->writeBytes(&binary[0], binaryLength); stream->writeBytes(binary.data(), binaryLength);
reapplyUBOBindingsIfNeeded(context); reapplyUBOBindingsIfNeeded(context);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment