Commit 425809bc authored by Michael Reeves's avatar Michael Reeves

fix multiple potential null pointer conditions found by clang-tindy

parent 65b8d2bf
---
Checks: '-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-optin.performance.Padding'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
User: michael
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
......@@ -346,7 +346,7 @@ bool SourceData::FileData::readFile(const QString& filename)
bool bSuccess = fa.readFile(pBuf, m_size);
if(!bSuccess)
{
delete pBuf;
delete[] pBuf;
m_pBuf = 0;
m_size = 0;
}
......
......@@ -1488,7 +1488,7 @@ void DiffTextWindow::setSelection(int firstLine, int startPos, int lastLine, int
endPos = d->m_pLineData[line].width(d->m_pOptions->m_tabSize);
}
if(d->m_bWordWrap && d->m_pDiff3LineVector != 0)
if(d->m_bWordWrap && d->m_pDiff3LineVector != NULL)
{
QString s1 = d->getString(firstLine);
int firstWrapLine = convertDiff3LineIdxToLine(firstLine);
......@@ -1517,10 +1517,12 @@ void DiffTextWindow::setSelection(int firstLine, int startPos, int lastLine, int
}
else
{
d->m_selection.start(firstLine, convertToPosOnScreen(d->getString(firstLine), startPos, d->m_pOptions->m_tabSize));
d->m_selection.end(lastLine, convertToPosOnScreen(d->getString(lastLine), endPos, d->m_pOptions->m_tabSize));
l = firstLine;
p = startPos;
if(d->m_pDiff3LineVector != NULL){
d->m_selection.start(firstLine, convertToPosOnScreen(d->getString(firstLine), startPos, d->m_pOptions->m_tabSize));
d->m_selection.end(lastLine, convertToPosOnScreen(d->getString(lastLine), endPos, d->m_pOptions->m_tabSize));
l = firstLine;
p = startPos;
}
}
update();
}
......
......@@ -157,7 +157,7 @@ KDiff3App::KDiff3App(QWidget* pParent, const char* /*name*/, KDiff3Part* pKDiff3
}
// All default values must be set before calling readOptions().
m_pOptionDialog = new OptionDialog(m_pKDiff3Shell != 0, this);
m_pOptionDialog = new OptionDialog(m_pKDiff3Shell != NULL, this);
connect(m_pOptionDialog, &OptionDialog::applyDone, this, &KDiff3App::slotRefresh);
// This is just a convenience variable to make code that accesses options more readable
......@@ -515,9 +515,10 @@ KDiff3App::~KDiff3App()
void KDiff3App::initActions(KActionCollection* ac)
{
if(ac == 0)
if(ac == 0){
KMessageBox::error(0, "actionCollection==0");
exit(-1);//we cann't recover from this.
}
fileOpen = KStandardAction::open(this, SLOT(slotFileOpen()), ac);
fileOpen->setStatusTip(i18n("Opens documents for comparison..."));
......@@ -811,7 +812,7 @@ void printDiffTextWindow(MyPainter& painter, const QRect& view, const QString& h
void KDiff3App::slotFilePrint()
{
if(!m_pDiffTextWindow1)
if(m_pDiffTextWindow1 == NULL)
return;
#ifdef QT_NO_PRINTER
slotStatusMsg(i18n("Printing not implemented."));
......@@ -822,9 +823,9 @@ void KDiff3App::slotFilePrint()
int firstSelectionD3LIdx = -1;
int lastSelectionD3LIdx = -1;
if(m_pDiffTextWindow1) {
m_pDiffTextWindow1->getSelectionRange(&firstSelectionD3LIdx, &lastSelectionD3LIdx, eD3LLineCoords);
}
m_pDiffTextWindow1->getSelectionRange(&firstSelectionD3LIdx, &lastSelectionD3LIdx, eD3LLineCoords);
if(firstSelectionD3LIdx < 0 && m_pDiffTextWindow2) {
m_pDiffTextWindow2->getSelectionRange(&firstSelectionD3LIdx, &lastSelectionD3LIdx, eD3LLineCoords);
}
......
......@@ -1789,8 +1789,9 @@ void KDiff3App::slotFinishRecalcWordWrap()
m_pDiffVScrollBar->setRange(0, max2(0, m_neededLines + 1 - m_DTWHeight));
if(m_pDiffTextWindow1)
{
m_pDiffVScrollBar->setValue(m_pDiffTextWindow1->convertDiff3LineIdxToLine(m_firstD3LIdx));
if(m_pDiffVScrollBar)
m_pDiffVScrollBar->setValue(m_pDiffTextWindow1->convertDiff3LineIdxToLine(m_firstD3LIdx));
setHScrollBarRange();
m_pHScrollBar->setValue(0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment