postmodern / ffi-hunspell

Ruby FFI bindings for Hunspell.
MIT License
48 stars 24 forks source link

FFI::NullPointerError: invalid memory read at address #1

Closed hamin closed 3 years ago

hamin commented 13 years ago

Hi,

I'm running into a weird null pointer error when using a custom dictionary. Here's how I'm able to recreate it:

foo.dic

2
apple
orange

Then trying to do something like this, I get the null pointer error:

dict = FFI::Hunspell::Dictionary.new("foo.aff","foo.dic")
dict.suggest("logically") # => FFI::NullPointerError: invalid memory read at address=0x00000000000000

Any ideas to what's going on here? Btw I'm using ruby 1.9.2 on os x 10.6

ownercoder commented 13 years ago

if !ptr.null? stems = ptr.get_array_of_string(0,count) end

in file dictionary.rb

If your wanna patch, i can send to your by email

hamin commented 13 years ago

that's cool, how bout forking the project and submitting a pull request?

postmodern commented 13 years ago

This is interesting, that would mean there is some libhunspell error that I'm not checking for (or can't see?).

ownercoder commented 13 years ago

I think, this error, with ffi, because binary hunspell working through libhunsplell. This error arises, while i trying suggest or check somethin like this: "gj3984jgfldk", but while i trying check or suggest with hunspell binary this error does not arise. Maybe i'm wrong :)

postmodern commented 3 years ago

This should be fixed in c7cfb16c25e9c78ecaf2b006aca871e0a0847d2f where a count > 0 check was added, which should indicate the pointer has been written to.