From 42d9576cbe8b76e1dd9cb7e5b698c6aa64734dce Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Fri, 6 Mar 2020 14:10:56 -0500 Subject: [PATCH] Fix dangling pointer after hipUnbindTexture() call Change-Id: Ic4b476c62ebfae31e94dd139b20b6aaaa52bb866 [ROCm/hip commit: dbb8f96a8e154c0eafaef2fa08dfc49247139a06] --- projects/hip/vdi/hip_texture.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/hip/vdi/hip_texture.cpp b/projects/hip/vdi/hip_texture.cpp index bab61340ca..db405810a6 100644 --- a/projects/hip/vdi/hip_texture.cpp +++ b/projects/hip/vdi/hip_texture.cpp @@ -597,10 +597,13 @@ hipError_t hipUnbindTexture(const textureReference* texref) { HIP_INIT_API(hipUnbindTexture, texref); if (texref == nullptr) { - return hipErrorInvalidValue; + HIP_RETURN(hipErrorInvalidValue); } - HIP_RETURN(ihipDestroyTextureObject(texref->textureObject)); + const hipTextureObject_t textureObject = texref->textureObject; + const_cast(texref)->textureObject = nullptr; + + HIP_RETURN(ihipDestroyTextureObject(textureObject)); } hipError_t hipBindTexture(size_t* offset,