anjia0532 / lua-resty-maxminddb

A Lua library for reading MaxMind's Geolocation database
Apache License 2.0
97 stars 30 forks source link

Prevent occasional SEGV when freeing list #24

Closed Hoops closed 4 years ago

Hoops commented 4 years ago

The maxminddb API seems to need a pointer to the first element when passing to MMDB_free_entry_data_list. Observed occasional SEGVs under heavy load without this fix.

We just save a the head of the list before dumping and pass that to MMDB_free_entry_data_list.

Note this is the same way they do it in the C API:

https://github.com/maxmind/libmaxminddb/blob/fc183662e85cb1b252c2f0272dc41f79e52e50fa/src/maxminddb.c#L730.

CC #8, #9

anjia0532 commented 4 years ago

LGTM

anjia0532 commented 4 years ago

thanks for your job