Skip to content

Commit

Permalink
Handle includer_ in CompileOptions copy/move constructors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pknowles committed Aug 5, 2023
1 parent 4d98dac commit 09f5e3f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libshaderc/include/shaderc/shaderc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 09f5e3f

Please sign in to comment.