aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src/observer_lib.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2017-10-17 19:23:58 +0200
committerSiri Hansen <[email protected]>2017-10-24 14:38:39 +0200
commit24c79977c7974d5415b6d4f7085a651ce1048e6a (patch)
tree70a8f069dab6750af446cc1bab071047c060f4b1 /lib/observer/src/observer_lib.erl
parent541ee20b9eaefed7802f08cecddfbd12e5f3b516 (diff)
downloadotp-24c79977c7974d5415b6d4f7085a651ce1048e6a.tar.gz
otp-24c79977c7974d5415b6d4f7085a651ce1048e6a.tar.bz2
otp-24c79977c7974d5415b6d4f7085a651ce1048e6a.zip
[observer] Don't crash on empty binary
Commit e1310b8f introduced a bug which caused the observer tool (and crashdump_viewer) to crash when trying to display an empty binary. The same change would also cause leading zeros in a binary to disappear in the preview. The bug is now corrected.
Diffstat (limited to 'lib/observer/src/observer_lib.erl')
-rw-r--r--lib/observer/src/observer_lib.erl8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/observer/src/observer_lib.erl b/lib/observer/src/observer_lib.erl
index 29f4f9fabc..94d199e688 100644
--- a/lib/observer/src/observer_lib.erl
+++ b/lib/observer/src/observer_lib.erl
@@ -810,7 +810,7 @@ progress_dialog_destroy({Dialog,_,_}) ->
make_obsbin(Bin,Tab) ->
Size = byte_size(Bin),
- Preview =
+ {Preview,PreviewBitSize} =
try
%% The binary might be a unicode string, in which case we
%% don't want to split it in the middle of a grapheme
@@ -819,14 +819,14 @@ make_obsbin(Bin,Tab) ->
PB1 = string:slice(Bin,0,PL1),
PS1 = byte_size(PB1) * 8,
<<P1:PS1>> = PB1,
- P1
+ {P1,PS1}
catch _:_ ->
%% Probably not a string, so just split anywhere
PS2 = min(Size, 10) * 8,
<<P2:PS2, _/binary>> = Bin,
- P2
+ {P2,PS2}
end,
Hash = erlang:phash2(Bin),
Key = {Preview, Size, Hash},
ets:insert(Tab, {Key,Bin}),
- ['#OBSBin',Preview,Size,Hash].
+ ['#OBSBin',Preview,PreviewBitSize,Size,Hash].