seanohalpin / ffi-ncurses

Interface to ncurses using Ruby FFI (Foreign Function Interface)
MIT License
82 stars 21 forks source link

getstr puts nulls in string which crash mvaddstr #17

Open rkumar opened 6 years ago

rkumar commented 6 years ago

I was just checking out the getstr/getnstr functions. If I fill the string with characters, everything goes fine. But if I enter a fewer characters than the size of the string passed to getstr, then mvprintw crashes with an error saying:

stdscr1.rb:15:in `mvaddstr': string contains null byte (ArgumentError)

I found I could work-around this by doing a str.strip before printing. Incidentally, puts does not give a problem with the same string.

stdscr1.rb.gz

Run the attached file. Remove the line that strips str and the exception is thrown. Try entering less than 8 chars and you get the error. I get the same error with getstr and getnstr.

(p.s, this is not critical. For all I know, this is a bug in the underlying platform) I am on Mac OS Sierra 10.12.6 (16G1212). ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16] I believe I am using the stock libncurses 5.4

Best wishes, Rahul Kumar (Hope all is well, Sean. ffi-ncurses is still going strong! Thanks for your efforts)