[Bf-blender-cvs] [644d54a193e] master: GPU: Fix memory leak in VkShader.

Jeroen Bakker noreply at git.blender.org
Thu Feb 2 13:06:34 CET 2023


Commit: 644d54a193e234a73a9606368da726ff54643b84
Author: Jeroen Bakker
Date:   Thu Feb 2 13:06:10 2023 +0100
Branches: master
https://developer.blender.org/rB644d54a193e234a73a9606368da726ff54643b84

GPU: Fix memory leak in VkShader.

std::string makes a copy, without taking ownership.

===================================================================

M	source/blender/gpu/vulkan/vk_shader.cc

===================================================================

diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc
index 79583fd8255..17c06fb42e6 100644
--- a/source/blender/gpu/vulkan/vk_shader.cc
+++ b/source/blender/gpu/vulkan/vk_shader.cc
@@ -521,7 +521,9 @@ static char *glsl_patch_get()
 static std::string combine_sources(Span<const char *> sources)
 {
   char *sources_combined = BLI_string_join_arrayN((const char **)sources.data(), sources.size());
-  return std::string(sources_combined);
+  std::string result(sources_combined);
+  MEM_freeN(sources_combined);
+  return result;
 }
 
 Vector<uint32_t> VKShader::compile_glsl_to_spirv(Span<const char *> sources,



More information about the Bf-blender-cvs mailing list