eagleas / clamav

ClamAV Ruby bindings
25 stars 9 forks source link

TypeError: can't convert false into Integer #1

Closed farleyknight closed 14 years ago

farleyknight commented 15 years ago

Hi,

I noticed just today that my application was failing because of something with ClamAV. I found that this line was causing the problem:

ClamAV.new TypeError: can't convert false into Integer from (irb):2:in `new' from (irb):2

I looked at your code and it seems that it's casting v_options and v_db_options to integers, causing to show up as 0 on my machine:

static VALUE clamavr_new(argc, argv, klass) int argc; VALUE argv; VALUE klass; { const char v_fname; int v_options; int v_db_options;

rb_scan_args(argc, argv, "02", &v_options, &v_db_options);
if(NIL_P(v_options)){
  v_options = INT2FIX(CL_SCAN_STDOPT); /* default value */
}
if(NIL_P(v_db_options)){
  v_db_options = INT2FIX(CL_DB_STDOPT); /* default value */
}

I changed the int's to VALUE's and the problem went away. I might be an anomaly on my machine, but I'm not sure. Is there any reason to use ints instead of VALUEs for this case? Anyways, just thought I'd let you know.

Thanks,

eagleas commented 15 years ago

If you call constructor with argument - false, it's real problem, options should be only integer. Give me please your code example.

warp commented 15 years ago

I have the same problem. I think v_options is a pointer so on 32bit systems an int is ok but on 64bit systems it needs to be long or VALUE

farleyknight commented 15 years ago

Ah yea, that makes sense. This was occurring on a Rackspace cloud server, which appears to be 64 bit. Thanks for that bit of info.

eagleas commented 14 years ago

Sorry for longtime silence. I pushed warp's changes, and try on 64-bit. It work fine. Version 0.3.1 is out.