We should not deserialize function blocks only containing opcodes, but not a function
This commit is contained in:
parent
25ef7e7fe3
commit
41860b041e
@ -302,6 +302,9 @@ deserialize_functions(<<?FUNCTION:8, A, B, C, D, Rest/binary>>,
|
||||
Program#{ BB => lists:reverse(Code)}}}},
|
||||
deserialize_functions(Rest2, Env2)
|
||||
end;
|
||||
deserialize_functions(<<Op:8, Rest/binary>>,
|
||||
#{ function := none }) ->
|
||||
error({code_without_function});
|
||||
deserialize_functions(<<Op:8, Rest/binary>>,
|
||||
#{ bb := BB
|
||||
, current_bb_code := Code
|
||||
@ -343,6 +346,7 @@ deserialize_op(Op, Rest, Code) ->
|
||||
|
||||
deserialize_n_args(N, <<M3:2, M2:2, M1:2, M0:2, Rest/binary>>) when N =< 4 ->
|
||||
ArgMods = lists:sublist([M0, M1, M2, M3], N),
|
||||
%% If N == 1 then we take M0 and don't care about the others. Should we check that the others are 0??
|
||||
lists:mapfoldl(fun(M, Acc) ->
|
||||
case bits_to_modifier(M) of
|
||||
stack ->
|
||||
|
@ -269,12 +269,18 @@ deserialize_types(N, Binary, Acc) ->
|
||||
rlp_encode_int(S) when S >= 0 ->
|
||||
aeser_rlp:encode(binary:encode_unsigned(S)).
|
||||
|
||||
|
||||
%% first byte of the binary gives the number of bytes we need <<129>> is 1, <<130>> = 2,
|
||||
%% so <<129, 0>> is <<0>> and <<130, 0, 0>> is <<0, 0>>
|
||||
rlp_decode_int(Binary) ->
|
||||
case aeser_rlp:decode_one(Binary) of
|
||||
{<<>>, _} ->
|
||||
error({illegal_integer_encoding, Binary});
|
||||
{Bin1, Rest} ->
|
||||
{binary:decode_unsigned(Bin1), Rest}
|
||||
{Bin1, Rest} = aeser_rlp:decode_one(Binary),
|
||||
Int = binary:decode_unsigned(Bin1),
|
||||
ReEncode = rlp_encode_int(Int),
|
||||
case <<ReEncode/binary, Rest/binary>> == Binary of
|
||||
true ->
|
||||
{Int, Rest};
|
||||
false ->
|
||||
error({none_unique_encoding, Bin1, ReEncode})
|
||||
end.
|
||||
|
||||
serialize_integer(I) when ?IS_FATE_INTEGER(I) ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user