Sly14 / freetype-gl

Automatically exported from code.google.com/p/freetype-gl
Other
0 stars 0 forks source link

vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" ); throws heap exceptions in C++ project on calling free #65

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Use freetype as external lib in VC10 or VC11 project.
2.
3.

Throws _BLOCK_TYPE_IS_INVALID on line 90 (free(desc))

in vertex-buffer.c

What is the expected output? What do you see instead?
It doesn't happen when running it in freetype-gl C examples.

What version of the product are you using? On what operating system?
Win7 64bit ,VisualStudio2012  .VC10 ,VC11

Please provide any additional information below.

Original issue reported on code.google.com by michael....@idomoo.com on 12 Nov 2013 at 2:34

GoogleCodeExporter commented 9 years ago
Btw,I debugged the block in vertex-buffer. c (lines 78- 90) and found that the 
free(desc) crashes only on the last attribute "color:4f" which in turn the only 
one which sets desc with strup(start),the previous two set desc with 
strnup.Maybe usage of strup somehow causes location being freed by free() to 
get invalid?

Original comment by michael....@idomoo.com on 12 Nov 2013 at 4:00

GoogleCodeExporter commented 9 years ago
Ok,I fixed it.it becomes obvious if setting the lib to compile to C++ and not 
to C.In such a case the compiler throws error:

" The POSIX name for this item is deprecated. Instead, use the ISO C++ 
conformant name: _strdup  

"

So I replaced all strdup with  _strdup and free() doesn't throw errors 
anymore.Do you want to make this fix in the repo?

Original comment by michael....@idomoo.com on 12 Nov 2013 at 4:12

GoogleCodeExporter commented 9 years ago
This occurs also in VC2013, and _strdup fixes.

Original comment by kengo.na...@gmail.com on 22 Jan 2015 at 8:33