miyucy / brotli

MIT License
59 stars 14 forks source link

Crash when second argument is integer #42

Closed Souravgoswami closed 1 year ago

Souravgoswami commented 2 years ago

When I use this code:

> Brotli.deflate('hello ' * 100).bytesize
=> 21

It works reliably, and compresses very well.

But if I use this:

Brotli.deflate('hello ' * 100, 1).bytesize

It core dumps. dump.txt

Well, I do understand that I shouldn't pass the 2nd integer argument. But it's also not a good thing to crash the whole Ruby environment. In case, this is rails for example, and someone is doing that in byebug or something, it will crash whole server - and leaves a bad impression.

So if we don't accept integer, we can always check the type and raise rb_eArgError instead of crashing.