Fix possible dereferencing of invalid iterator
if low was equal to m_labelAddrOffsetMap.end(), the code
would dereference an invalid iterator. Flip the conditions
to ensure that the validity check is performed first.
MODIFY
src/programviewer.cpp
src/programviewer.cpp
@@ -260,7 +260,7 @@ long ProgramViewer::addressForBlock(QTextBlock block) const {
auto low = m_labelAddrOffsetMap.lower_bound(lineNumber);
- if (lineNumber < low->first && (low == m_labelAddrOffsetMap.begin())) {
+ if ((low == m_labelAddrOffsetMap.begin()) && lineNumber < low->first) {
// The line number is less that the position of the first offset block; address is directly inferred from
// linenumber.
return calcAddressFunc(adjustedLineNumber);

Fix possible dereferencing of invalid iterator

if low was equal to m_labelAddrOffsetMap.end(), the code
would dereference an invalid iterator. Flip the conditions
to ensure that the validity check is performed first.