summaryrefslogtreecommitdiff
path: root/src/plugins/bineditor
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-03-08 16:54:12 +0200
committerOrgad Shaneh <orgads@gmail.com>2016-03-08 15:22:05 +0000
commit90571432280a36f5e9ef5da468f832cf1d973f66 (patch)
treea15a0a631cbffab98993d339f9bd2d9bc852ff60 /src/plugins/bineditor
parent83e3d954f9a8721644b21404421194a60f971094 (diff)
downloadqt-creator-90571432280a36f5e9ef5da468f832cf1d973f66.tar.gz
BinEditor: Fix crash on editor initialization
MemoryAgent::doCreateBinEditor calls openEditorWithContents, with empty contents. The BinEditor fails to handle this case, and crashes when it divides by zero. Task-number: QTCREATORBUG-15835 Change-Id: I8009ef991a445ef4cc192d1bda6a208d51e2b48b Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/plugins/bineditor')
-rw-r--r--src/plugins/bineditor/bineditor.cpp1
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp6
2 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp
index 41d4155f46..ef3f2b31c4 100644
--- a/src/plugins/bineditor/bineditor.cpp
+++ b/src/plugins/bineditor/bineditor.cpp
@@ -376,6 +376,7 @@ bool BinEditorWidget::save(QString *errorString, const QString &oldFileName, con
void BinEditorWidget::setSizes(quint64 startAddr, int range, int blockSize)
{
int newBlockSize = blockSize;
+ QTC_ASSERT(blockSize, return);
QTC_ASSERT((blockSize/m_bytesPerLine) * m_bytesPerLine == blockSize,
blockSize = (blockSize/m_bytesPerLine + 1) * m_bytesPerLine);
// Users can edit data in the range
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 1d686b5912..cce44ebebe 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -243,8 +243,10 @@ public:
bool setContents(const QByteArray &contents) override
{
m_widget->clear();
- m_widget->setSizes(0, contents.length(), contents.length());
- m_widget->addData(0, contents);
+ if (!contents.isEmpty()) {
+ m_widget->setSizes(0, contents.length(), contents.length());
+ m_widget->addData(0, contents);
+ }
return true;
}