openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
761 stars 376 forks source link

lime_system_get_directory segfault #392

Closed ibilon closed 9 years ago

ibilon commented 9 years ago

Trying to run the HaxePunk sample result in a segfault, I looked into it and found out that System::GetDirectory returns 0, which alloc_string don't like.

https://github.com/openfl/lime/blob/master/project/src/ExternalInterface.cpp#L595

returning alloc_string("") when that's the case seems to fix the problem.

jgranick commented 9 years ago

Does it work to return alloc_null (); in these cases?

When does it return null?

ibilon commented 9 years ago

It enters the FONTS case https://github.com/openfl/lime/blob/master/project/src/backend/sdl/SDLSystem.cpp#L95 but since I'm on linux it falls through and return 0 https://github.com/openfl/lime/blob/master/project/src/backend/sdl/SDLSystem.cpp#L155

returning alloc_null works.

jgranick commented 9 years ago

Oh, that's a mistake. It should probably return "/usr/fonts"?

ibilon commented 9 years ago

Seems to be dependent of the distribution, from what I could see most of them put the fonts in /usr/share/fonts/.

On my openSUSE it's a lot of directories and a lot of fonts in /usr/share/fonts/truetype. On a debian I have access /usr/share/fonts/truetype is full of directories, some ttf in /usr/share/fonts/truetype/freefont/.

jgranick commented 9 years ago

Yeah, let's probably use /usr/share/fonts/truetype as the standard return

Hasufel commented 9 years ago

Confirmed on Ubuntu for /usr/share/fonts/truetype

jgranick commented 9 years ago

Should be fixed now, thanks guys :smile: