emanonwzy / ftk

Automatically exported from code.google.com/p/ftk
Other
0 stars 0 forks source link

fontextract Segmentation fault if input is gb2312.txt #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. ./fontextract wqy-microhei.ttc 24 gb2312.txt 2.f

What do you see instead?
code=0022 width=8 height=6
Segmentation fault
I have trace that it crash at fontextract.c : 79

What version of the product are you using? On what operating system?
I had test under ubuntu 10.04 and vc2008 (Mtd), both freetype version is 2.3.11.

Please provide any additional information below.
I have trace that if realloc(ptr, 0) may cause freetype crash.
But I have not search that some one had mentioned about it.
realloc.patch is that avoid to realloc(ptr, 0), but realloc(ptr, 1).
With the patch, It does not crash under ubuntu 10.04 and vc2008 (Mtd)

Original issue reported on code.google.com by andy.xie...@gmail.com on 24 Apr 2013 at 4:28

GoogleCodeExporter commented 8 years ago
--- fontdata.c  (revision 1221)
+++ fontdata.c  (working copy)
@@ -244,7 +244,7 @@
                        if((thiz->data_size + size) >= thiz->data_buffer_size)
                        {
                                size_t data_buffer_size = thiz->data_buffer_size + (thiz->data_buffer_size >> 1) + (size << 4);
-                               unsigned char* data = (unsigned 
char*)FTK_REALLOC(thiz->data, data_buffer_size);
+                               unsigned char* data = (unsigned 
char*)FTK_REALLOC(thiz->data, data_buffer_size ? data_buffer_size : 1);
                                if(data != NULL)
                                {
                                        thiz->data = data;

Original comment by andy.xie...@gmail.com on 24 Apr 2013 at 4:29

Attachments: