diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp
index e48e8f09eb21f806d574bb50fbbc2bcb2c6565d4..3d5b99f27563b380a1cc616a2f3bab6e7a3377f9 100644
--- a/Graphics/drawContext.cpp
+++ b/Graphics/drawContext.cpp
@@ -416,9 +416,11 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick)
         }
         if(!_bgImageSize[0] || !_bgImageSize[1]){
           Msg::Error("Could not load valid background image");
+          // make sure we don't try to load it again
           for(int i = 0; i < 3; i++) _bgImage.push_back(0);
           _bgImageSize[0] = _bgImageSize[1] = 1.;
         }
+        if(img) delete img;
       }
       double x = CTX::instance()->bgImagePosition[0];
       double y = CTX::instance()->bgImagePosition[1];