Browse files

Fix bitstring handling bug (crashing eunit only!)

Thanks to fishcakez, stuff needs to be reported :)
  • Loading branch information...
1 parent 7611e1c commit 3804b05333fd3e3643ce1ba03f7255ceedca8a1d @aerosol aerosol committed Oct 29, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/binpp.erl
View
6 src/binpp.erl
@@ -114,7 +114,7 @@ convert(Bin, [], FormatFun) when is_bitstring(Bin), not is_binary(Bin) ->
%% byte align bistring() to make a complementary binary()
Align = (8 - (bit_size(Bin) rem 8)),
error_logger:info_msg("Aligned bitstring with ~.10B bit(s).~n", [Align]),
- convert(<<Bin/binary, 0:Align>>, [], FormatFun);
+ convert(<<Bin/bitstring, 0:Align>>, [], FormatFun);
convert(<<Bin:8/integer, Rest/binary>>, SoFar, FormatFun) ->
convert(Rest, [FormatFun(Bin)|SoFar], FormatFun).
@@ -252,7 +252,9 @@ convert_test_() ->
Tests = [
{ <<1,2,3>>, ["01", "02", "03"] },
{ <<256:32>>, ["00", "00", "01", "00"] },
- { <<"AAA">>, ["41", "41", "41"] }
+ { <<"AAA">>, ["41", "41", "41"] },
+ { <<256:7>>, ["00"] },
+ { <<256:9>>, ["80", "00"] }
],
[ { <<"Convert">>, fun() -> ?assertEqual({ok, R}, F(I)) end } || { I, R } <- Tests ].

0 comments on commit 3804b05

Please sign in to comment.