From f896f7ffc32a6f7ffa2152f356102afe1d3d1286 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 17 Mar 2025 16:18:31 +0100 Subject: [PATCH] Fix #136047: Cycles OSL gettextureinfo crash with missing image Missing null pointer check. Pull Request: https://projects.blender.org/blender/blender/pulls/136075 --- intern/cycles/kernel/osl/services.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp index b59df54beec..6d1708c7e42 100644 --- a/intern/cycles/kernel/osl/services.cpp +++ b/intern/cycles/kernel/osl/services.cpp @@ -1598,19 +1598,26 @@ bool OSLRenderServices::get_texture_info(OSLUStringHash filename, OSLUStringHash * /*errormessage*/) { OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle; - - /* No texture info for other texture types. */ - if (handle && handle->type != OSLTextureHandle::OIIO) { - return false; - } - - /* Get texture info from OpenImageIO. */ OSL::TextureSystem *ts = m_texturesys; - if (handle->oiio_handle) { - return ts->get_texture_info( - handle->oiio_handle, texture_thread_info, subimage, to_ustring(dataname), datatype, data); + + if (handle) { + /* No texture info for other texture types. */ + if (handle->type != OSLTextureHandle::OIIO) { + return false; + } + + if (handle->oiio_handle) { + /* Get texture info from OpenImageIO. */ + return ts->get_texture_info(handle->oiio_handle, + texture_thread_info, + subimage, + to_ustring(dataname), + datatype, + data); + } } + /* Get texture info from OpenImageIO, slower using filename. */ return ts->get_texture_info( to_ustring(filename), subimage, to_ustring(dataname), datatype, data); }