dbalatero / levenshtein-ffi

Fast string edit distance computation, using the Damerau-Levenshtein algorithm.
BSD 2-Clause "Simplified" License
149 stars 24 forks source link

Seg.fault when passed nils #2

Closed harbu closed 10 years ago

harbu commented 12 years ago

Hi, great extension!

I noticed that if you pass distance a nil argument it will cause a segmentation fault. Maybe there could be a nil check in the Ruby code?

ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

dbalatero commented 12 years ago

Sure, want to add it?

What is the correct behaviour for a nil argument? Should this be the case:

distance(nil, "string") # => 6
distance("string", nil) # => 6
distance(nil, nil) # => 0? raise an exception?
mutewinter commented 11 years ago

Just got bit by this also. Would be awesome if it checked for nils and at least through an exception.

dbalatero commented 10 years ago

This is fixed in master, closing.