Guard get/set/delete to require list arguments
BugzID: 25731
diff --git a/src/config.erl b/src/config.erl
index 98b5221..1a728b0 100644
--- a/src/config.erl
+++ b/src/config.erl
@@ -124,7 +124,7 @@
get(Section) when is_binary(Section) ->
?MODULE:get(binary_to_list(Section));
-get(Section) ->
+get(Section) when is_list(Section) ->
Matches = ets:match(?MODULE, {{Section, '$1'}, '$2'}),
[{Key, Value} || [Key, Value] <- Matches].
@@ -133,7 +133,7 @@
get(Section, Key, Default) when is_binary(Section) and is_binary(Key) ->
?MODULE:get(binary_to_list(Section), binary_to_list(Key), Default);
-get(Section, Key, Default) ->
+get(Section, Key, Default) when is_list(Section), is_list(Key) ->
case ets:lookup(?MODULE, {Section, Key}) of
[] -> Default;
[{_, Match}] -> Match
@@ -149,7 +149,8 @@
set(Sec, Key, Val, Persist, Reason) when is_binary(Sec) and is_binary(Key) ->
?MODULE:set(binary_to_list(Sec), binary_to_list(Key), Val, Persist, Reason);
-set(Section, Key, Value, Persist, Reason) ->
+set(Section, Key, Value, Persist, Reason)
+ when is_list(Section), is_list(Key), is_list(Value) ->
gen_server:call(?MODULE, {set, Section, Key, Value, Persist, Reason}).
@@ -165,7 +166,7 @@
delete(Sec, Key, Persist, Reason) when is_binary(Sec) and is_binary(Key) ->
delete(binary_to_list(Sec), binary_to_list(Key), Persist, Reason);
-delete(Section, Key, Persist, Reason) ->
+delete(Section, Key, Persist, Reason) when is_list(Section), is_list(Key) ->
gen_server:call(?MODULE, {delete, Section, Key, Persist, Reason}).