From e4f60fa0be4374d0e38f295a0a301430fc98e4f4 Mon Sep 17 00:00:00 2001 From: Tomek Ponitka Date: Mon, 7 Sep 2020 12:05:28 +0000 Subject: [PATCH] [spirv-writer] Fixing memory leaks in texture intrinsics tests The variables are no longer released. Bug: tint:143 Change-Id: I56a3edd0e7acb3c729aa82851879d69e510298db Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28164 Reviewed-by: Corentin Wallez Commit-Queue: Tomek Ponitka --- src/writer/spirv/builder_intrinsic_test.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc index 8027b81f04..dc1cbefbe6 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -471,12 +471,13 @@ class Builder_TextureOperation void add_call_param(std::string name, ast::type::Type* type, ast::ExpressionList* call_params) { - auto var = - std::make_unique(name, ast::StorageClass::kNone, type); - td()->RegisterVariableForTesting(var.get()); + variables_.push_back( + std::make_unique(name, ast::StorageClass::kNone, type)); + td()->RegisterVariableForTesting(variables_.back().get()); call_params->push_back(std::make_unique(name)); - ASSERT_TRUE(b()->GenerateGlobalVariable(var.release())) << b()->error(); + ASSERT_TRUE(b()->GenerateGlobalVariable(variables_.back().get())) + << b()->error(); } std::unique_ptr subtype(TextureType type) { @@ -556,6 +557,7 @@ class Builder_TextureOperation ast::Module mod_; std::unique_ptr td_; std::unique_ptr b_; + std::vector> variables_; }; class Builder_TextureLoad : public Builder_TextureOperation {