Fix T46109: Bitmap font objects leads to unfreed memory.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 14 Sep 2015 15:12:40 +0000 (17:12 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 14 Sep 2015 15:12:40 +0000 (17:12 +0200)
source/blender/imbuf/intern/allocimbuf.c

index b8771e372cf8988efe770a156045a2b86d3702d5..5c79eb2c544e896a381f1a94f2fc504e7ad49d4f 100644 (file)
@@ -128,6 +128,13 @@ void imb_freetilesImBuf(ImBuf *ibuf)
        ibuf->mall &= ~IB_tiles;
 }
 
+static void imb_free_bitmap_font(ImBuf *ibuf)
+{
+       if (ibuf->userdata && (ibuf->userflags & IB_BITMAPFONT)) {
+               MEM_freeN(ibuf->userdata);
+       }
+}
+
 static void freeencodedbufferImBuf(ImBuf *ibuf)
 {
        if (ibuf == NULL) return;
@@ -181,6 +188,7 @@ void IMB_freeImBuf(ImBuf *ibuf)
                        imb_freerectImBuf(ibuf);
                        imb_freerectfloatImBuf(ibuf);
                        imb_freetilesImBuf(ibuf);
+                       imb_free_bitmap_font(ibuf);
                        IMB_freezbufImBuf(ibuf);
                        IMB_freezbuffloatImBuf(ibuf);
                        freeencodedbufferImBuf(ibuf);