Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Revision:
69:636867df24a1
Parent:
61:8f3153bf0baa
Child:
72:ecffe56af969
--- a/GraphicsDisplay.cpp	Sun Aug 17 15:38:51 2014 +0000
+++ b/GraphicsDisplay.cpp	Sun Aug 31 15:54:42 2014 +0000
@@ -439,7 +439,9 @@
             //HexDump("Line", lineBuffer, lineBufSize);
             fwrite(lineBuffer, sizeof(char), lb, Image);
         }
-        fclose(Image);       
+        fclose(Image);
+        free(pixelBuffer);  // don't leak memory.
+        free(lineBuffer);
         INFO("Image closed"); 
         return noerror;
     } else {
@@ -453,6 +455,7 @@
     RGBQUAD * colorPalette = NULL;
     int colorCount;
     uint8_t * lineBuffer = NULL;
+    color_t * pixelBuffer = NULL;
     uint16_t BPP_t;
     uint32_t PixelWidth, PixelHeight;
     unsigned int    i, offset;
@@ -500,10 +503,11 @@
         fclose(Image);
         return(not_enough_ram);
     }
-    color_t * pixelBuffer = (color_t *)malloc(PixelWidth * sizeof(color_t));
+    pixelBuffer = (color_t *)malloc(PixelWidth * sizeof(color_t));
     if (pixelBuffer == NULL) {
-        free(colorPalette);
         free(lineBuffer);
+        if (colorPalette)
+            free(colorPalette);
         fclose(Image);
         return(not_enough_ram);
     }
@@ -562,8 +566,10 @@
     }
     _EndGraphicsStream();
     WindowMax();
+    free(pixelBuffer);      // don't leak memory
     free(lineBuffer);
-    free(colorPalette);
+    if (colorPalette)
+        free(colorPalette);
     return (noerror);
 }