fxfactorial / ocaml-maxminddb

:earth_asia: OCaml Bindings to libmaxminddb, think GeoIP2
http://hyegar.com
7 stars 2 forks source link

Eventual segmentation faults when Maxminddb.create fails #3

Open mfp opened 6 years ago

mfp commented 6 years ago

When Maxminddb.create fails (e.g. because it is given a path to a non-existent file), a custom block is created and not initialized properly: https://github.com/fxfactorial/ocaml-maxminddb/blob/888e2ebb3b09ff1b1cf3889e9ba24174fb6ea498/src/maxminddb_stubs.c#L122-L124 (where check_status raises an Invalid_argument error if the MMDB handle could not be created). Eventually, the custom block is recovered, and its finalizer function calls MMDB_close on an invalid MMDB handle, thus segfaulting.

fxfactorial commented 6 years ago

Thank you,

Open to PRs or I will have to get to this in about six weeks.