erickguan / ffi-icu

FFI wrappers for ICU. MRI extension with the dynamic C library.
https://github.com/erickguan/ffi-icu
MIT License
35 stars 22 forks source link

Increase read_uchar_buffer sizes for Locale #38

Closed damiann closed 5 years ago

damiann commented 5 years ago

Increase the read_uchar_buffer size for Locale: display_script, display_country, display_language, display_name

Depending on the locales you use it throws an out of bounds memory error, which results in a Segmentation fault error.

Currently, these are the max character byte sizes:

(dev)> ICU::Locale.new('en-VI').display_name('ccp')
IndexError: Memory access offset=0 size=180 is out of bounds
from /bundle/gems/ffi-icu-0.1.10/lib/ffi-icu/uchar.rb:41:in `read_array_of_uint16'

Longest character byte sizes:

display_script = ICU::Locale.new('yue_Hant').display_script('ccp')
display_script.bytesize # => 91
display_country = ICU::Locale.new('en_VI').display_country('ccp')
display_country.bytesize # => 209
display_language = ICU::Locale.new('zgh').display_language('ccp')
display_language.bytesize # => 151
display_name = ICU::Locale.new('en_VI').display_name('ccp')
display_name.bytesize # => 254
damiann commented 5 years ago

For Travis, I swapped unsupported Ruby versions with supported versions.