Mesa (main): microsoft/clc: Fix test double free in the case of compilation failure

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 27 17:04:33 UTC 2022


Module: Mesa
Branch: main
Commit: fd37959680725e0b3f96a4e91757bcc0d8d60e7e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fd37959680725e0b3f96a4e91757bcc0d8d60e7e

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Sun Jun 26 20:58:24 2022 -0700

microsoft/clc: Fix test double free in the case of compilation failure

Reviewed-by: Bill Kristiansen <billkris at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17246>

---

 src/microsoft/clc/compute_test.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/microsoft/clc/compute_test.cpp b/src/microsoft/clc/compute_test.cpp
index 07543e1bd3b..1171e37ef2c 100644
--- a/src/microsoft/clc/compute_test.cpp
+++ b/src/microsoft/clc/compute_test.cpp
@@ -848,13 +848,14 @@ ComputeTest::configure(Shader &shader,
          throw runtime_error("failed to parse spirv!");
    }
 
-   shader.dxil = std::shared_ptr<clc_dxil_object>(new clc_dxil_object{}, [](clc_dxil_object *dxil)
+   std::unique_ptr<clc_dxil_object> dxil(new clc_dxil_object{});
+   if (!clc_spirv_to_dxil(compiler_ctx, shader.obj.get(), shader.metadata.get(), "main_test", conf, nullptr, &logger, dxil.get()))
+      throw runtime_error("failed to compile kernel!");
+   shader.dxil = std::shared_ptr<clc_dxil_object>(dxil.release(), [](clc_dxil_object *dxil)
       {
          clc_free_dxil_object(dxil);
          delete dxil;
       });
-   if (!clc_spirv_to_dxil(compiler_ctx, shader.obj.get(), shader.metadata.get(), "main_test", conf, nullptr, &logger, shader.dxil.get()))
-      throw runtime_error("failed to compile kernel!");
 }
 
 void



More information about the mesa-commit mailing list