Skip to content

Commit 38ff3a1

Browse files
committed
GUI: fixed various bugs (thanks to Coverity)
1 parent 5a214ab commit 38ff3a1

24 files changed

+44
-29
lines changed

x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
241241
bool bCanResize = (getColumnWidth(mColResizeData.index) + delta) >= 20;
242242
if(bCanResize)
243243
{
244-
int wNewSize = bCanResize ? (getColumnWidth(mColResizeData.index) + delta) : (20);
244+
int wNewSize = getColumnWidth(mColResizeData.index) + delta;
245245
setColumnWidth(mColResizeData.index, wNewSize);
246246
mColResizeData.lastPosX = event->x();
247247
repaint();
@@ -456,7 +456,7 @@ void AbstractTableView::keyPressEvent(QKeyEvent* event)
456456
*/
457457
void AbstractTableView::vertSliderActionSlot(int action)
458458
{
459-
int_t wDelta;
459+
int_t wDelta = 0;
460460
int wSliderPos = verticalScrollBar()->sliderPosition();
461461
int wNewScrollBarValue;
462462

x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,6 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
343343
Function_t funcType;
344344
switch(loopType)
345345
{
346-
case LOOP_NONE:
347-
funcType = Function_none;
348-
break;
349346
case LOOP_BEGIN:
350347
funcType = Function_start;
351348
break;
@@ -358,6 +355,8 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
358355
case LOOP_END:
359356
funcType = Function_end;
360357
break;
358+
default:
359+
break;
361360
}
362361
loopsize += paintFunctionGraphic(painter, x + loopsize, y, funcType, true);
363362
depth++;
@@ -1481,6 +1480,6 @@ QString Disassembly::getAddrText(int_t cur_addr, char label[MAX_LABEL_SIZE])
14811480
else
14821481
*label_ = 0;
14831482
if(label)
1484-
strcpy(label, label_);
1483+
strcpy_s(label, MAX_LABEL_SIZE, label_);
14851484
return addrText;
14861485
}

x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ HistoryLineEdit::HistoryLineEdit(QWidget* parent) : QLineEdit(parent)
44
{
55
mCmdHistory.clear();
66
mCmdIndex = -1;
7+
bSixPressed = false;
78
}
89

910
void HistoryLineEdit::addLineToHistory(QString parLine)

x64_dbg_gui/Project/Src/BasicView/ShortcutEdit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
ShortcutEdit::ShortcutEdit(QWidget* parent) : QLineEdit(parent)
44
{
5+
keyInt = -1;
56
}
67

78
const QKeySequence ShortcutEdit::getKeysequence() const

x64_dbg_gui/Project/Src/BasicView/ShortcutEdit.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class ShortcutEdit : public QLineEdit
99
{
1010
Q_OBJECT
11-
QKeySequence key;
1211
int keyInt;
1312

1413
public:

x64_dbg_gui/Project/Src/BasicView/StdTable.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ StdTable::StdTable(QWidget* parent) : AbstractTableView(parent)
1212
mData.clear();
1313
mSort.first = -1;
1414

15+
mGuiState = StdTable::NoState;
16+
1517
mCopyMenuOnly = false;
1618
mCopyMenuDebugOnly = true;
1719
setContextMenuPolicy(Qt::CustomContextMenu);

x64_dbg_gui/Project/Src/Bridge/Bridge.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ static Bridge* mBridge;
1515
Bridge::Bridge(QObject* parent) : QObject(parent)
1616
{
1717
mBridgeMutex = new QMutex();
18+
winId = 0;
19+
scriptView = 0;
20+
referenceView = 0;
21+
bridgeResult = 0;
22+
hasBridgeResult = false;
1823
}
1924

2025
Bridge::~Bridge()
@@ -634,8 +639,8 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
634639
byte_t wBuffer[16];
635640
if(!DbgMemRead(parVA, wBuffer, 16))
636641
return 0;
637-
QBeaEngine* disasm = new QBeaEngine();
638-
Instruction_t instr = disasm->DisassembleAt(wBuffer, 16, 0, 0, parVA);
642+
QBeaEngine disasm;
643+
Instruction_t instr = disasm.DisassembleAt(wBuffer, 16, 0, 0, parVA);
639644
BeaTokenizer::TokenizeInstruction(&instr.tokens, &instr.disasm);
640645
QList<RichTextPainter::CustomRichText_t> richText;
641646
BeaTokenizer::TokenToRichText(&instr.tokens, &richText, 0);

x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,8 @@ void CPUDisassembly::assembleAt()
813813

814814
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), wRVA, wMaxByteCountToRead);
815815

816-
QBeaEngine* disasm = new QBeaEngine();
817-
Instruction_t instr = disasm->DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, 0, wVA);
816+
QBeaEngine disasm;
817+
Instruction_t instr = disasm.DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, 0, wVA);
818818

819819
LineEditDialog mLineEdit(this);
820820
mLineEdit.setText(instr.instStr);

x64_dbg_gui/Project/Src/Gui/CPUInfoBox.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CPUInfoBox::CPUInfoBox(StdTable* parent) : StdTable(parent)
1717
setMinimumHeight(height);
1818
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(dbgStateChanged(DBGSTATE)));
1919
connect(this, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(contextMenuSlot(QPoint)));
20+
curAddr = 0;
2021
}
2122

2223
int CPUInfoBox::getHeight()

x64_dbg_gui/Project/Src/Gui/CPUSideBar.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ CPUSideBar::CPUSideBar(CPUDisassembly* Ptr, QWidget* parent) : QAbstractScrollAr
2020
InstrBuffer = CodePtr->instructionsBuffer();
2121

2222
backgroundColor = ConfigColor("SideBarBackgroundColor");
23+
24+
memset(&regDump, 0, sizeof(REGDUMP));
2325
}
2426

2527
QSize CPUSideBar::sizeHint() const

x64_dbg_gui/Project/Src/Gui/CommandHelpView.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CommandHelpView::CommandHelpView(QWidget* parent) : QWidget(parent), ui(new Ui::
55
{
66
ui->setupUi(this);
77

8+
mCurrentMode = 0;
9+
810
// Set main layout
911
mMainLayout = new QVBoxLayout;
1012
mMainLayout->setContentsMargins(0, 0, 0, 0);

x64_dbg_gui/Project/Src/Gui/CommandHelpView.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ private slots:
2828
private:
2929
Ui::CommandHelpView* ui;
3030
QVBoxLayout* mMainLayout;
31-
QVBoxLayout* mSymbolLayout;
32-
QWidget* mSymbolPlaceHolder;
3331
SearchListView* mSearchListView;
3432
StdTable* mModuleList;
3533
int mCurrentMode;

x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ExceptionRangeDialog::ExceptionRangeDialog(QWidget* parent) :
1313
ui->editStart->setCursorPosition(0);
1414
ui->editEnd->setCursorPosition(0);
1515
ui->btnOk->setEnabled(false);
16+
rangeStart = 0;
17+
rangeEnd = 0;
1618
}
1719

1820
ExceptionRangeDialog::~ExceptionRangeDialog()

x64_dbg_gui/Project/Src/Gui/LineEditDialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LineEditDialog::LineEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Li
99
setFixedSize(this->size()); //fixed size
1010
setModal(true); //modal window
1111
ui->checkBox->hide();
12+
bChecked = false;
1213
}
1314

1415
LineEditDialog::~LineEditDialog()

x64_dbg_gui/Project/Src/Gui/MainWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ void MainWindow::restartDebugging()
546546
char filename[MAX_SETTING_SIZE] = "";
547547
if(!mMRUList.size())
548548
return;
549-
strcpy(filename, mMRUList.at(0).toUtf8().constData());
549+
strcpy_s(filename, mMRUList.at(0).toUtf8().constData());
550550
if(DbgIsDebugging())
551551
{
552552
DbgCmdExec("stop"); //close current file (when present)

x64_dbg_gui/Project/Src/Gui/PageMemoryRights.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PageMemoryRights::PageMemoryRights(QWidget* parent) : QDialog(parent), ui(new Ui
77
//set window flags
88
setModal(true);
99
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
10+
addr = 0;
11+
size = 0;
1012
}
1113

1214
PageMemoryRights::~PageMemoryRights()

x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
1616
setFixedSize(this->size()); //fixed size
1717
LoadSettings(); //load settings from file
1818
connect(Bridge::getBridge(), SIGNAL(setLastException(uint)), this, SLOT(setLastException(uint)));
19+
lastException = 0;
1920
}
2021

2122
SettingsDialog::~SettingsDialog()

x64_dbg_gui/Project/Src/Gui/ShortcutsDialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ShortcutsDialog::ShortcutsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::
1313
QStringList tblHeader;
1414
tblHeader << "Instruction" << "Shortcut";
1515

16+
currentRow = 0;
17+
1618
ui->tblShortcuts->setColumnCount(2);
1719
ui->tblShortcuts->verticalHeader()->setVisible(false);
1820
ui->tblShortcuts->setHorizontalHeaderLabels(tblHeader);

x64_dbg_gui/Project/Src/Gui/ShortcutsDialog.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ class ShortcutsDialog : public QDialog
1515
Q_OBJECT
1616
Configuration::Shortcut currentShortcut;
1717
int currentRow;
18-
bool editLock;
18+
1919
public:
2020
explicit ShortcutsDialog(QWidget* parent = 0);
2121
~ShortcutsDialog();
22-
signals:
23-
2422

2523
protected slots:
2624
void syncTextfield();

x64_dbg_gui/Project/Src/Gui/TabWidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void MHTabWidget::setCurrentIndex(int index)
6868

6969
void MHTabWidget::setCurrentWidget(QWidget* widget)
7070
{
71-
widget = 0;
71+
Q_UNUSED(widget);
7272
// To be implemented.
7373
}
7474

@@ -124,7 +124,7 @@ void MHTabWidget::DetachTab(int index, QPoint & dropPoint)
124124
void MHTabWidget::AttachTab(QWidget* parent)
125125
{
126126
// Retrieve widget
127-
MHDetachedWindow* detachedWidget = dynamic_cast<MHDetachedWindow*>(parent);
127+
MHDetachedWindow* detachedWidget = reinterpret_cast<MHDetachedWindow*>(parent);
128128
QWidget* tearOffWidget = detachedWidget->centralWidget();
129129

130130
// Reattach the tab

x64_dbg_gui/Project/Src/QHexEdit/ArrayCommand.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CharCommand::CharCommand(XByteArray* xData, Cmd cmd, int charPos, char newChar,
66
_charPos = charPos;
77
_newChar = newChar;
88
_cmd = cmd;
9+
_oldChar = 0;
910
}
1011

1112
bool CharCommand::mergeWith(const QUndoCommand* command)

x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public slots:
5858

5959
private:
6060
QHexEditPrivate* qHexEdit_p;
61-
QHBoxLayout* layout;
62-
QScrollArea* scrollArea;
6361
};
6462

6563
#endif

x64_dbg_gui/Project/Src/Utils/Breakpoints.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void Breakpoints::setBP(BPXTYPE type, uint_t va)
5454
*
5555
* @return Nothing.
5656
*/
57-
void Breakpoints::enableBP(BRIDGEBP bp)
57+
void Breakpoints::enableBP(BRIDGEBP & bp)
5858
{
5959
QString wCmd = "";
6060

@@ -112,7 +112,7 @@ void Breakpoints::enableBP(BPXTYPE type, uint_t va)
112112
*
113113
* @return Nothing.
114114
*/
115-
void Breakpoints::disableBP(BRIDGEBP bp)
115+
void Breakpoints::disableBP(BRIDGEBP & bp)
116116
{
117117
QString wCmd = "";
118118

@@ -170,7 +170,7 @@ void Breakpoints::disableBP(BPXTYPE type, uint_t va)
170170
*
171171
* @return Nothing.
172172
*/
173-
void Breakpoints::removeBP(BRIDGEBP bp)
173+
void Breakpoints::removeBP(BRIDGEBP & bp)
174174
{
175175
QString wCmd = "";
176176

@@ -244,7 +244,7 @@ void Breakpoints::removeBP(BPXTYPE type, uint_t va)
244244
*
245245
* @return Nothing.
246246
*/
247-
void Breakpoints::toggleBPByDisabling(BRIDGEBP bp)
247+
void Breakpoints::toggleBPByDisabling(BRIDGEBP & bp)
248248
{
249249
if(bp.enabled == true)
250250
disableBP(bp);

x64_dbg_gui/Project/Src/Utils/Breakpoints.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ class Breakpoints : public QObject
1717
public:
1818
explicit Breakpoints(QObject* parent = 0);
1919
static void setBP(BPXTYPE type, uint_t va);
20-
static void enableBP(BRIDGEBP bp);
20+
static void enableBP(BRIDGEBP & bp);
2121
static void enableBP(BPXTYPE type, uint_t va);
22-
static void disableBP(BRIDGEBP bp);
22+
static void disableBP(BRIDGEBP & bp);
2323
static void disableBP(BPXTYPE type, uint_t va);
24-
static void removeBP(BRIDGEBP bp);
24+
static void removeBP(BRIDGEBP & bp);
2525
static void removeBP(BPXTYPE type, uint_t va);
26-
static void toggleBPByDisabling(BRIDGEBP bp);
26+
static void toggleBPByDisabling(BRIDGEBP & bp);
2727
static void toggleBPByDisabling(BPXTYPE type, uint_t va);
2828
static void toggleBPByRemoving(BPXTYPE type, uint_t va);
2929
static BPXSTATE BPState(BPXTYPE type, uint_t va);

0 commit comments

Comments
 (0)