diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 4892a292cf3f791cf1235142c2e567ffd5156d43..7188b0fa440666cd39e62e0b0c58ae74d8d4ca4d 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1424,7 +1424,7 @@ void LLImageGL::deleteDeadTextures()
 		{
 			LLTexUnit* tex_unit = gGL.getTexUnit(i);
 
-			if (tex_unit->getCurrTexture() == tex)
+			if (tex_unit && tex_unit->getCurrTexture() == tex)
 			{
 				tex_unit->unbind(tex_unit->getCurrType());
 				stop_glerror();