diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-07-15 11:12:09 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-07-15 11:12:09 -0700 |
commit | d064ac9334be079d0e830bc2361c065cbaa52a64 (patch) | |
tree | eb7f29bfec1cade37d9252d88bf09e9d5f2e3b32 | |
parent | dcaa9f9be83bfd59503033ae8f8eeca79c68c9df (diff) | |
download | kgio-d064ac9334be079d0e830bc2361c065cbaa52a64.tar.gz |
We want more descriptive error messages and don't want crazy stuff like floats.
-rw-r--r-- | ext/kgio/connect.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/kgio/connect.c b/ext/kgio/connect.c index c16556e..dd2f409 100644 --- a/ext/kgio/connect.c +++ b/ext/kgio/connect.c @@ -63,7 +63,11 @@ static VALUE tcp_connect(VALUE klass, VALUE ip, VALUE port, int io_wait) struct addrinfo *res; const char *ipname = StringValuePtr(ip); char ipport[6]; - unsigned uport = FIX2UINT(port); + unsigned uport; + + if (TYPE(port) != T_FIXNUM) + rb_raise(rb_eTypeError, "port must be a non-negative integer"); + uport = FIX2UINT(port); rc = snprintf(ipport, sizeof(ipport), "%u", uport); if (rc >= (int)sizeof(ipport) || rc <= 0) |