Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RA8875 by
Diff: GraphicsDisplay.cpp
- Revision:
- 69:636867df24a1
- Parent:
- 61:8f3153bf0baa
- Child:
- 72:ecffe56af969
diff -r ba5d33438fda -r 636867df24a1 GraphicsDisplay.cpp
--- 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);
}
