Skip to content

Commit

Permalink
Merge pull request mochi#1 from gleber/master
Browse files Browse the repository at this point in the history
Fixed pretty impressive crash while passing IP as a tuple to the lookup/2 function.
  • Loading branch information
lemenkov committed May 19, 2011
2 parents f560008 + 8338b62 commit 43b43a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/egeoip.erl
Expand Up @@ -358,7 +358,7 @@ handle_info(Info, State) ->
get_worker(Address) ->
element(1 + erlang:phash2(Address) band 7,
egeoip_sup:worker_names()).

%% @spec new() -> {ok, geoipdb()}
%% @doc Create a new geoipdb database record using the default
%% priv/GeoLiteCity.dat.gz database.
Expand Down Expand Up @@ -386,7 +386,8 @@ new(Path) ->

%% @spec lookup(D::geoipdb(), Addr) -> {ok, geoip()}
%% @doc Lookup a geoip record for Addr using the database D.
lookup(D, Addr) when is_list(Addr) ->
lookup(D, Addr) when is_list(Addr);
is_tuple(Addr) ->
case ip2long(Addr) of
{ok, Ip} ->
lookup(D, Ip);
Expand Down

0 comments on commit 43b43a8

Please sign in to comment.