mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Pass the buffer size into DeserializeWGPUDeviceProperties
This allows deserialization to fail if the buffer is not large enough. Before, we simply assumed the buffer was at least the size of WGPUDeviceProperties. Bug: none Change-Id: I24e1f84c583f48d4e32c35276e5508e257e9f530 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/39861 Auto-Submit: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
387a597154
commit
9a2174a37c
@@ -34,8 +34,24 @@ TEST_F(WireWGPUDevicePropertiesTests, SerializeWGPUDeviceProperties) {
|
||||
dawn_wire::SerializeWGPUDeviceProperties(&sentWGPUDeviceProperties, buffer.data());
|
||||
|
||||
WGPUDeviceProperties receivedWGPUDeviceProperties;
|
||||
dawn_wire::DeserializeWGPUDeviceProperties(&receivedWGPUDeviceProperties, buffer.data());
|
||||
ASSERT_TRUE(dawn_wire::DeserializeWGPUDeviceProperties(&receivedWGPUDeviceProperties,
|
||||
buffer.data(), buffer.size()));
|
||||
ASSERT_TRUE(receivedWGPUDeviceProperties.textureCompressionBC);
|
||||
ASSERT_FALSE(receivedWGPUDeviceProperties.pipelineStatisticsQuery);
|
||||
ASSERT_TRUE(receivedWGPUDeviceProperties.timestampQuery);
|
||||
}
|
||||
|
||||
// Test that deserialization if the buffer is just one byte too small fails.
|
||||
TEST_F(WireWGPUDevicePropertiesTests, DeserializeBufferTooSmall) {
|
||||
WGPUDeviceProperties sentWGPUDeviceProperties = {};
|
||||
|
||||
size_t sentWGPUDevicePropertiesSize =
|
||||
dawn_wire::SerializedWGPUDevicePropertiesSize(&sentWGPUDeviceProperties);
|
||||
std::vector<char> buffer;
|
||||
buffer.resize(sentWGPUDevicePropertiesSize);
|
||||
dawn_wire::SerializeWGPUDeviceProperties(&sentWGPUDeviceProperties, buffer.data());
|
||||
|
||||
WGPUDeviceProperties receivedWGPUDeviceProperties;
|
||||
ASSERT_FALSE(dawn_wire::DeserializeWGPUDeviceProperties(&receivedWGPUDeviceProperties,
|
||||
buffer.data(), buffer.size() - 1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user