diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index 32c13f0d74..86434140fa 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -844,6 +844,7 @@ namespace dawn_native { std::unique_ptr compilationMessages( std::make_unique()); if (ConsumedError(CreateShaderModule(descriptor, compilationMessages.get()), &result)) { + DAWN_ASSERT(result == nullptr); result = ShaderModuleBase::MakeError(this); } // Move compilation messages into ShaderModuleBase and emit tint errors and warnings diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index bdff7a7aec..4c23874d4a 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -1307,8 +1307,8 @@ namespace dawn_native { } // static - ShaderModuleBase* ShaderModuleBase::MakeError(DeviceBase* device) { - return new ShaderModuleBase(device, ObjectBase::kError); + Ref ShaderModuleBase::MakeError(DeviceBase* device) { + return AcquireRef(new ShaderModuleBase(device, ObjectBase::kError)); } bool ShaderModuleBase::HasEntryPoint(const std::string& entryPoint) const { diff --git a/src/dawn_native/ShaderModule.h b/src/dawn_native/ShaderModule.h index dd3d34a993..271704295e 100644 --- a/src/dawn_native/ShaderModule.h +++ b/src/dawn_native/ShaderModule.h @@ -166,7 +166,7 @@ namespace dawn_native { ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor); ~ShaderModuleBase() override; - static ShaderModuleBase* MakeError(DeviceBase* device); + static Ref MakeError(DeviceBase* device); // Return true iff the program has an entrypoint called `entryPoint`. bool HasEntryPoint(const std::string& entryPoint) const;