Skip to content

Commit bbe1a85

Browse files
committed
Ensure that all members of LinearView and HexEditor are initialized
Most members were initialized within the constructor, but a couple were only initialized later and could in some cases be accessed before being initialized. Members of types without default constructors are now initialized via default member initializers unless they're initialized in the class's member initializer list.
1 parent e69f1b5 commit bbe1a85

File tree

2 files changed

+44
-37
lines changed

2 files changed

+44
-37
lines changed

ui/hexeditor.h

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -196,29 +196,35 @@ class BINARYNINJAUIAPI HexEditor :
196196
ViewFrame* m_view;
197197

198198
std::vector<HexEditorLine> m_lines;
199-
size_t m_topLine;
200-
uint64_t m_topAddr, m_bottomAddr;
199+
size_t m_topLine = 0;
200+
uint64_t m_topAddr = 0;
201+
uint64_t m_bottomAddr = 0;
201202

202203
std::vector<BNAddressRange> m_ranges;
203-
uint64_t m_allocatedLength;
204-
uint64_t m_scrollBarMultiplier;
205-
int m_wheelDelta;
206-
bool m_updatingScrollBar;
207-
bool m_updatesRequired;
208-
209-
uint64_t m_minAddr;
210-
uint64_t m_cursorAddr, m_prevCursorAddr;
211-
int m_cursorOffset;
212-
uint64_t m_selectionStartAddr;
213-
int m_cols, m_visibleRows;
214-
int m_lastMouseX, m_lastMouseY;
215-
bool m_selectionVisible;
216-
bool m_cursorAscii;
217-
bool m_caretVisible, m_caretBlink;
218-
bool m_insertMode;
204+
uint64_t m_allocatedLength = 0;
205+
uint64_t m_scrollBarMultiplier = 0;
206+
int m_wheelDelta = 0;
207+
bool m_updatingScrollBar = false;
208+
bool m_updatesRequired = false;
209+
210+
uint64_t m_minAddr = 0;
211+
uint64_t m_cursorAddr = 0;
212+
uint64_t m_prevCursorAddr = 0;
213+
int m_cursorOffset = 0;
214+
uint64_t m_selectionStartAddr = 0;
215+
int m_cols = 0;
216+
int m_visibleRows = 1;
217+
int m_lastMouseX = 0;
218+
int m_lastMouseY = 0;
219+
bool m_selectionVisible = false;
220+
bool m_cursorAscii = false;
221+
bool m_caretVisible = false;
222+
bool m_caretBlink = true;
223+
bool m_insertMode = false;
219224
QString m_status;
220-
QTimer* m_cursorTimer;
221-
Qt::KeyboardModifiers m_ctrl, m_command;
225+
QTimer* m_cursorTimer = nullptr;
226+
Qt::KeyboardModifiers m_ctrl = Qt::ControlModifier;
227+
Qt::KeyboardModifiers m_command = Qt::MetaModifier;
222228

223229
RenderContext m_render;
224230
HexEditorHighlightState m_highlightState;

ui/linearview.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,25 @@ class BINARYNINJAUIAPI LinearView : public QAbstractScrollArea, public View, pub
187187

188188
BinaryViewRef m_data;
189189
ViewFrame* m_view;
190-
uint64_t m_allocatedLength;
190+
uint64_t m_allocatedLength = 0;
191191

192-
StickyHeader* m_header;
192+
StickyHeader* m_header = nullptr;
193193
RenderContext m_render;
194-
int m_cols, m_rows;
195-
uint64_t m_scrollBarMultiplier;
196-
int m_wheelDelta;
197-
bool m_updatingScrollBar;
194+
int m_cols = 0;
195+
int m_rows = 0;
196+
uint64_t m_scrollBarMultiplier = 0;
197+
int m_wheelDelta = 0;
198+
bool m_updatingScrollBar = false;
198199

199-
std::atomic<bool> m_updatesRequired;
200-
bool m_updateBounds;
200+
std::atomic<bool> m_updatesRequired = false;
201+
bool m_updateBounds = false;
201202

202203
LinearViewCursorPosition m_cursorPos, m_selectionStartPos;
203-
bool m_cursorAscii;
204+
bool m_cursorAscii = false;
204205
bool m_tokenSelection = false;
205206
HighlightTokenState m_highlight;
206207
bool m_displayCollapseIndicators = false;
207-
uint64_t m_navByRefTarget;
208+
uint64_t m_navByRefTarget = 0;
208209
bool m_navByRef = false;
209210
bool m_doubleClickLatch = false;
210211
FunctionRef m_relatedHighlightFunction;
@@ -217,27 +218,27 @@ class BINARYNINJAUIAPI LinearView : public QAbstractScrollArea, public View, pub
217218
HexEditorHighlightState m_highlightState;
218219
bool m_singleFunctionView = false;
219220

220-
InstructionEdit* m_instrEdit;
221+
InstructionEdit* m_instrEdit = nullptr;
221222

222-
BNAddressRange m_cacheBounds;
223+
BNAddressRange m_cacheBounds = { 0, 0 };
223224
std::vector<BNAddressRange> m_cachedRegions;
224225
std::shared_mutex m_cacheMutex;
225226
BinaryNinja::Ref<BinaryNinja::LinearViewCursor> m_topPosition, m_bottomPosition;
226227
std::vector<LinearViewLine> m_lines;
227-
size_t m_emptyPrevCursors;
228-
size_t m_emptyNextCursors;
229-
size_t m_topLine;
228+
size_t m_emptyPrevCursors = 0;
229+
size_t m_emptyNextCursors = 0;
230+
size_t m_topLine = 0;
230231
std::optional<double> m_topOrderingIndexOffset;
231232

232-
QTimer* m_hoverTimer;
233+
QTimer* m_hoverTimer = nullptr;
233234
QPointF m_previewPos;
234235

235236
ContextMenuManager* m_contextMenuManager;
236237
QPointer<CommentDialog> m_commentDialog;
237238

238239
std::map<FunctionRef, BinaryNinja::AdvancedFunctionAnalysisDataRequestor> m_analysisRequestors;
239240

240-
std::string m_navigationMode = "";
241+
std::string m_navigationMode;
241242

242243
ClickableIcon* m_dataButton = nullptr;
243244
QWidget* m_dataButtonContainer = nullptr;

0 commit comments

Comments
 (0)