Merge pull request #76 from aeternity/dont_crash_on_deserialize

Don't crash in decode_calldata for FATE
This commit is contained in:
Hans Svensson 2019-09-05 14:26:00 +02:00 committed by GitHub
commit a533fd5fcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,9 +37,11 @@ create_calldata(FunName, Args) ->
-spec decode_calldata(list(), binary()) -> {ok, term()} | {error, term()}. -spec decode_calldata(list(), binary()) -> {ok, term()} | {error, term()}.
decode_calldata(FunName, Calldata) -> decode_calldata(FunName, Calldata) ->
FunctionId = aeb_fate_code:symbol_identifier(list_to_binary(FunName)), FunctionId = aeb_fate_code:symbol_identifier(list_to_binary(FunName)),
case ?FATE_TUPLE_ELEMENTS(aeb_fate_encoding:deserialize(Calldata)) of try ?FATE_TUPLE_ELEMENTS(aeb_fate_encoding:deserialize(Calldata)) of
[FunctionId, FateArgs] -> {ok, ?FATE_TUPLE_ELEMENTS(FateArgs)}; [FunctionId, FateArgs] -> {ok, ?FATE_TUPLE_ELEMENTS(FateArgs)};
_ -> {error, decode_error} _ -> {error, decode_error}
catch _:_ ->
{error, decode_error}
end. end.
-spec get_function_name_from_function_hash(binary(), aeb_fate_code:fcode()) -> -spec get_function_name_from_function_hash(binary(), aeb_fate_code:fcode()) ->