Skip to content

Commit

Permalink
Fix potential function clause for non-atom table names
Browse files Browse the repository at this point in the history
  • Loading branch information
schlagert committed Dec 7, 2015
1 parent ee21c45 commit 8710a88
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/lbm_kv_merge.erl
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ merge_entry(Local, Remote, Table, Key) ->
%% This hidden feature could (in the future) be used to call the user-provided
%% callback to merge non-lbm_kv tables ;)
%%------------------------------------------------------------------------------
user_callback(Table, Key, LRecord, RRecord) ->
Error = {error, {diverged, Table, Key}},
user_callback(Table, Key, LRecord, RRecord) when is_atom(Table) ->
case code:ensure_loaded(Table) of
{module, Table} ->
case erlang:function_exported(Table, resolve_conflict, 3) of
Expand All @@ -195,14 +194,16 @@ user_callback(Table, Key, LRecord, RRecord) ->
_ ->
noop
catch _:_ ->
Error
{error, {diverged, Table, Key}}
end;
false ->
Error
{error, {diverged, Table, Key}}
end;
_ ->
Error
end.
{error, {diverged, Table, Key}}
end;
user_callback(Table, Key, _, _) ->
{error, {diverged, Table, Key}}.

%%------------------------------------------------------------------------------
%% @private
Expand Down

0 comments on commit 8710a88

Please sign in to comment.