Skip to contentSkip to conversation

video: truetype: Fix a memory leak on error

PATCH New Simon Glass 2 participants 4 messages Feb 22, 2016 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 video: truetype: Fix a memory leak on error

When the resolution is not supported we should free the memory we don't plan to use.

Reported-by Coverity (CID: 135127)

---

 drivers/video/console_truetype.c | 1 +
 1 file changed, 1 insertion(+)
drivers/video/console_truetype.c +1 -0
index c249f04..e16f95a 100644
@@ -289,6 +289,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 		}
 #endif
 		default:
+			free(data);
 			return -ENOSYS;
 		}
 
Signature · 1 line
2.7.0.rc3.207.g0ac5344
#1 lore raw

PATCH 2/2 video: freetype: Fix a memory leak with a bad parameter

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

Reported-by Coverity (CID: 24068)

---

 drivers/video/stb_truetype.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/stb_truetype.h +4 -1
index 91d8e6f..26e483c 100644
@@ -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;
    }
 
Signature · 1 line
2.7.0.rc3.207.g0ac5344
#2 lore raw

PATCH 2/2 video: freetype: Fix a memory leak with a bad parameter

Quoted 8 lines · On Sun, 21 Feb 2016 21:10:26 -0700 Simon Glass sjg at chromium.org wrote:

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

Reported-by Coverity (CID: 24068)

---

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

appied to u-boot-video/master, thanks1

--
Anatolij

#3 lore raw

PATCH 1/2 video: truetype: Fix a memory leak on error

In reply to Simon Glass

Hi Simon,

Quoted 9 lines · On Sun, 21 Feb 2016 21:10:25 -0700 Simon Glass sjg at chromium.org wrote:

When the resolution is not supported we should free the memory we don't plan to use.

Reported-by Coverity (CID: 135127)

---

 drivers/video/console_truetype.c | 1 +

appied to u-boot-video/master, thanks1

--
Anatolij