diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 9dc140b5b98bfe42e1035e1b6d8234f4f0bf743b..465f30a3432c776addc2cc036fe8ec14d0cae179 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -859,9 +859,16 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
 							stop_glerror();
 
 							if (prev_mip_data)
-								delete[] prev_mip_data;
+							{
+								if (prev_mip_data != cur_mip_data)
+									delete[] prev_mip_data;
+								prev_mip_data = nullptr;
+							}
 							if (cur_mip_data)
+							{
 								delete[] cur_mip_data;
+								cur_mip_data = nullptr;
+							}
 							
 							mGLTextureCreated = false;
 							return FALSE;