From 09f5e3f04692bb82a5274284f3f6c560c5f086ff Mon Sep 17 00:00:00 2001 From: pknowles Date: Sat, 5 Aug 2023 01:54:43 -0700 Subject: [PATCH] Handle includer_ in CompileOptions copy/move constructors Copying CompileOptions() results in a new object with possibly dangling pointers to the old include callbacks. This patch just clears them, since includer_ doesn't have a way to clone() it. Moving CompileOptions() moves options_ but not includer_. This patch moves includer_ too. --- libshaderc/include/shaderc/shaderc.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libshaderc/include/shaderc/shaderc.hpp b/libshaderc/include/shaderc/shaderc.hpp index bc057c13d..b387e9293 100644 --- a/libshaderc/include/shaderc/shaderc.hpp +++ b/libshaderc/include/shaderc/shaderc.hpp @@ -143,8 +143,11 @@ class CompileOptions { ~CompileOptions() { shaderc_compile_options_release(options_); } CompileOptions(const CompileOptions& other) { options_ = shaderc_compile_options_clone(other.options_); + + // Clear the includer callbacks on the new object as it is not copyable. + shaderc_compile_options_set_include_callbacks(options_, nullptr, nullptr, nullptr); } - CompileOptions(CompileOptions&& other) { + CompileOptions(CompileOptions&& other) : includer_(std::move(other.includer_)) { options_ = other.options_; other.options_ = nullptr; }