diff --git a/geoip.c b/geoip.c index 085f6e1..f497298 100644 --- a/geoip.c +++ b/geoip.c @@ -43,6 +43,10 @@ void rb_hash_sset(VALUE hash, const char *str, VALUE v) { /* pulled from http://blog.inventic.eu/?p=238 and https://github.com/Vagabond/erlang-iconv/blob/master/c_src/iconv_drv.c */ static VALUE encode_to_utf8_and_return_rb_str(char *value) { + if (value == NULL) { + return Qnil; + } + char dst[BUFSIZ]; size_t srclen = strlen(value); size_t dstlen = srclen * 2;