Allocation failure fix
Intentional allocation failure tests were crashing on Linux,
because the object's constructor was called even when the
allocator returned nullptr. Separated the allocation from
the construction to fix the issue.
Bug b/116336664
Change-Id: I7a5d4e957ec27f37a96b795a7f17aacebb240fe9
Tests: dEQP-VK.api.device_init.create_instance_device_intentional_alloc_fail
Tests: dEQP-VK.api.object_management.alloc_callback_fail.*
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28948
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index fa6f3d8..34be31f 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -1104,6 +1104,7 @@
template<typename T, typename... Args>
void CommandBuffer::addCommand(Args&&... args)
{
+ // FIXME (b/119409619): use an allocator here so we can control all memory allocations
commands->push_back(std::unique_ptr<T>(new T(std::forward<Args>(args)...)));
}