[libdriver-integration-test] Fix ASAN failure
Copying std::initializer_list is a shallow copy, so passing it into a
promise closure by copy is unsafe.
Bug: ZX-4142 #done
Change-Id: I5e5b2090ebcec7324f3d637bc111dee238fdf1f9
diff --git a/garnet/tests/zircon/libdriver-integration-test/device-add-tests.cc b/garnet/tests/zircon/libdriver-integration-test/device-add-tests.cc
index 30cc5bd..a58481c 100644
--- a/garnet/tests/zircon/libdriver-integration-test/device-add-tests.cc
+++ b/garnet/tests/zircon/libdriver-integration-test/device-add-tests.cc
@@ -19,12 +19,15 @@
std::initializer_list<zx_device_prop_t> props, zx_status_t expected_status,
std::unique_ptr<RootMockDevice>* root_device,
std::unique_ptr<MockDevice>* child_device) {
+ // Copy from props into a vector owned by the lambda, since a capture "by
+ // value" of props does not copy deeply.
+ std::vector<zx_device_prop_t> properties(props);
return ExpectBind(root_device,
- [=](HookInvocation record, Completer<void> completer) {
+ [=, properties=std::move(properties)](HookInvocation record,
+ Completer<void> completer) {
ActionList actions;
actions.AppendAddMockDevice(loop_.dispatcher(), (*root_device)->path(),
- "first_child",
- std::vector<zx_device_prop_t>(props),
+ "first_child", std::move(properties),
expected_status, std::move(completer), child_device);
actions.AppendReturnStatus(expected_status);
return actions;