From 24c79977c7974d5415b6d4f7085a651ce1048e6a Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 17 Oct 2017 19:23:58 +0200 Subject: [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. --- lib/observer/src/observer_lib.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/observer/src/observer_lib.erl') 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, <> = PB1, - P1 + {P1,PS1} catch _:_ -> %% Probably not a string, so just split anywhere PS2 = min(Size, 10) * 8, <> = 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]. -- cgit v1.2.3