Skip to content

Commit 764414a

Browse files
pknowlespknowles
authored andcommitted
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.
1 parent 4d98dac commit 764414a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libshaderc/include/shaderc/shaderc.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,11 @@ class CompileOptions {
143143
~CompileOptions() { shaderc_compile_options_release(options_); }
144144
CompileOptions(const CompileOptions& other) {
145145
options_ = shaderc_compile_options_clone(other.options_);
146+
147+
// Clear the includer callbacks on the new object as it is not copyable.
148+
shaderc_compile_options_set_include_callbacks(options_, nullptr, nullptr, nullptr);
146149
}
147-
CompileOptions(CompileOptions&& other) {
150+
CompileOptions(CompileOptions&& other) : includer_(std::move(other.includer_)) {
148151
options_ = other.options_;
149152
other.options_ = nullptr;
150153
}

0 commit comments

Comments
 (0)