Commit 0b8eca79 by Jamie Madill Committed by Commit Bot

Capture/Replay: Fix CaptureShaderSource_string.

Was accessing a buffer out-of-bounds. Also wasn't handling negative length. Test: ASAN build Bug: angleproject:3611 Change-Id: I0f1cfa09d0488de20928d90e910803d98c225968 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1796082Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 79ad0411
......@@ -643,10 +643,11 @@ void CaptureShaderSource_string(const Context *context,
{
for (GLsizei index = 0; index < count; ++index)
{
size_t len = ((length && length[index] >= 0) ? length[index] : strlen(string[index]));
// includes the '\0' suffix
size_t len = (length ? length[index] : strlen(string[index])) + 1;
CaptureMemory(string[index], len, paramCapture);
paramCapture->data[paramCapture->data.size() - 1][len] = '\0';
std::vector<uint8_t> data(len + 1, 0);
memcpy(data.data(), string[index], len);
paramCapture->data.emplace_back(std::move(data));
}
}
......
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