[U-Boot] [PATCH 2/2] video: freetype: Fix a memory leak with a bad parameter

Simon Glass sjg at chromium.org
Mon Feb 22 05:10:26 CET 2016


Make sure to free memory used when the scale facture is incorrect.

Reported-by: Coverity (CID: 24068)
Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/video/stb_truetype.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/video/stb_truetype.h b/drivers/video/stb_truetype.h
index 91d8e6f..26e483c 100644
--- a/drivers/video/stb_truetype.h
+++ b/drivers/video/stb_truetype.h
@@ -2426,7 +2426,10 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info
 
    if (scale_x == 0) scale_x = scale_y;
    if (scale_y == 0) {
-      if (scale_x == 0) return NULL;
+      if (scale_x == 0) {
+         STBTT_free(vertices, info->userdata);
+         return NULL;
+      }
       scale_y = scale_x;
    }
 
-- 
2.7.0.rc3.207.g0ac5344



More information about the U-Boot mailing list