From 27449af4453f7c92b7f021a2b7ac0082cb47102d Mon Sep 17 00:00:00 2001 From: Paul I Date: Thu, 23 Jan 2020 02:07:41 +0300 Subject: [PATCH] Fix potential nullptr dereference (#2028) --- src/core/Cutter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 030ccb69..a876908d 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -1921,6 +1921,10 @@ void CutterCore::addBreakpoint(const BreakpointDescription &config) breakpoint = r_debug_bp_add(core->dbg, address, (config.hw && watchpoint_prot == 0), watchpoint_prot, watchpoint_prot, module, config.moduleDelta); + if (!breakpoint) { + QMessageBox::critical(nullptr, tr("Breakpoint error"), tr("Failed to create breakpoint")); + return; + } if (config.type == BreakpointDescription::Named) { updateOwnedCharPtr(breakpoint->expr, config.positionExpression); } @@ -1932,10 +1936,6 @@ void CutterCore::addBreakpoint(const BreakpointDescription &config) updateOwnedCharPtr(breakpoint->name, config.positionExpression); } - if (!breakpoint) { - QMessageBox::critical(nullptr, tr("Breakpoint error"), tr("Failed to create breakpoint")); - return; - } int index = std::find(core->dbg->bp->bps_idx, core->dbg->bp->bps_idx + core->dbg->bp->bps_idx_count, breakpoint) - core->dbg->bp->bps_idx;