From: Eric Wong Date: 2015-07-30T07:48:02+00:00 Subject: [ruby-core:70183] Re: [Ruby trunk - Bug #11400] IO.gets(/\x0d?\x0a\x0d?\x0a/, 4096) raises comparison of Fixnum with nil failed bar.hofesh@safe-t.com wrote: > Looking at the code it's clear the offending line is https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/buffering.rb#L216 > Where sometimes size would be nil, and because of "size = [size, limit].min" or more specifically > So: > > `[nil, 4096].min > ArgumentError: comparison of Fixnum with nil failed > from (pry):1:in `each'` Thanks. > You should use size.to_i or something :) size.to_i seems wrong since it would give zero. consume_rbuf can handle size=nil, so I think we should continue passing nil to consume_rbuff in this case. Totally untested patch below: --- a/ext/openssl/lib/openssl/buffering.rb +++ b/ext/openssl/lib/openssl/buffering.rb @@ -213,7 +213,7 @@ module OpenSSL::Buffering else size = idx ? idx+eol.size : nil end - if limit and limit >= 0 + if size && limit && limit >= 0 size = [size, limit].min end consume_rbuff(size) Care to test? Thanks! Would also be helpful to write a standalone test case so we can commit it to our test suite.