kuno / GeoIP

GeoIP binding for nodejs(>=0.10) and iojs
GNU Lesser General Public License v2.1
414 stars 129 forks source link

use of static to get the value of info #86

Open mlabour opened 8 years ago

mlabour commented 8 years ago

On https://github.com/kuno/GeoIP/blob/master/src/org.cc at line 74

Why having static Nan::Utf8String *host_cstr = new Nan::Utf8String(info[0]); Instead of Nan::Utf8String host_cstr(info[0]);

Thank you

kkoopa commented 8 years ago

As far as I can tell from looking at the code, these Utf8Strings are never deleted and will therefore leak. The above suggestion ought to work, as should this:

uint32_t ipnum = _GeoIP_lookupaddress(*Nan::Utf8String(info[0]));
kkoopa commented 8 years ago

Actually, it used to be that way, but was changed in b2efc95d093c4aff9057fe6c7a43702f8d0d23cb. If there actually was a segmentation fault somewhere, it means that libgeoip does something wrong or strange with strings passed in. Does it try to free them or does it store the pointer for future use?