Patch #3017 2010-07-08 16:40
csun
Fix Bug #17318 (Hex Editor crash)- Download
- 3017-Fix_Bug_17318.patch (515 bytes)
--- src/plugins/contrib/HexEditor/HexEditPanel.cpp (revision 6374)
+++ src/plugins/contrib/HexEditor/HexEditPanel.cpp (working copy)
@@ -771,7 +771,7 @@
}
else
{
- m_Status->SetLabel( F( _("Position: %llX / %llX ( %lld%% )"), m_Current, size-1, ( m_Current * 100 / (size-1) ) ) );
+ m_Status->SetLabel( F( _("Position: %llX / %llX ( %lld%% )"), m_Current, size-1, ( (size-1) == 0 ? 100 : m_Current * 100 / (size-1) ) ) );
}
FileContentBase::OffsetT left = size - m_Current;
History
csun 2010-07-08 16:43
The division by zero exception is caused by the "percentage of cursor position in the file" calculation (curr * 100) / (size - 1): if the size is 1 then a div by zero occurs.
This patch simply checks whether (size-1) is 0: if so return 100% (I'm assuming that this percentage standard for files of one byte - if not feel free to change it).
biplab 2010-07-23 16:25
A different patch has been applied. Refer rev 6413 for details.
Thanks for the bug report and patch. Your contribution is highly appreciated.