maxmind/libmaxminddb — pull request #41 by yangshuxin (2014-09-18 00:02:38+00:00)
Title: Fix a bug due to dangling pointer

The dangling pointer could incur real problem. This is the problem I run into:
My system is runing nginx built along with ngx_http_geoip2_module and libmaxminddb.
nginx is running with a configuration with a geoip2-directive specifying a file that
dose not exist. like this:

-----------------------------------------------------------
geoip2 /my/path/that/dose/not/exist/maxmind-country.mmdb {
$geoip2_data_country_code default=US country iso_code;
$geoip2_data_country_name country names en;
}
-----------------------------------------------------------

When Nginx is launched with this configuration, ngx_http_geoip2_module call
MMDB_open() which in turn calls free_mmdb_struct() as MMDB_open() was not
successfully open the specified .mmdb file.

Nginx then exit, calling ngx_http_geoip2_cleanup() which call MMDB_close(), which
call free_mmdb_struct().

NOTE that in this senario, free_mmdb_struct() is called *TWICE* upon the same
mmdb! The first call to free_mmdb_struct() yields bunch of dangling pointers, and
the 2nd call to free_mmdb_struct() will call free() on these dangling pointers.

This fix is just to set those pointer NULL right after the object they pointing
to are deallocated.