From 0a3bcbeb33d8036f9badd8746d7b697f66516529 Mon Sep 17 00:00:00 2001 From: Jimmy Chang Date: Tue, 11 Aug 2026 01:39:51 +0800 Subject: [PATCH] Fix null dereference when building a texture from memory The image constructor assigned the mip set to its parameter rather than to the member that PerformUpload reads, so `img` was still null by the time Upload dereferenced it. Any call to this constructor crashed. Assign to the member instead. --- engine/render/r_texture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/render/r_texture.cpp b/engine/render/r_texture.cpp index 07fdda80..ea901cde 100644 --- a/engine/render/r_texture.cpp +++ b/engine/render/r_texture.cpp @@ -310,8 +310,9 @@ r_tex_c::r_tex_c(r_ITexManager* manager, std::unique_ptr img, int flags { Init(manager, {}, flags); - // Direct upload - img = BuildMipSet(std::move(img)); + // Direct upload. The result has to land in the member `img`, which is what + // PerformUpload reads — assigning to the parameter left it null. + this->img = BuildMipSet(std::move(img)); PerformUpload(this); }