Commit 788fcb8b authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

https://scan.coverity.com/projects/3327 Coverity fixes listed by CID :

268381 Use after free in umlwidgets/diagramproxywidget.cpp
- In function slotMenuSelection case ListPopupMenu::mt_State_Diagram,
  if `ok` is true after the do-while loop then
  - assign d->view()->umlScene() to local variable `scene` before call
    to UMLApp::app()->executeCommand(d);
  - at calls to setDiagramLink and setWidgetLink use local `scene` in
    lieu of d->view()->umlScene().
    Reason: `d` may have been invalidated by the executeCommand call.

364153 Uninitialized scalar variable in dialogs/pages/
                                                selectoperationpage.cpp
- In copy constructor initialize m_enableAutoIncrement to false.
- In function slotAutoIncrementChecked assign `state` to
  m_enableAutoIncrement.
- As a related fix, in dialogs/selectoperationdialog.cpp function
  slotAutoIncrementChecked assign `state` to m_enableAutoIncrement.

364158 Resource leak in docgenerators/docbookgeneratorjob.cpp
- In function xsltprocExternalEntityLoader split the statement
        if (newURL != NULL && defaultEntityLoader != NULL) {
  into two statements
        if (newURL != NULL) {
            if (defaultEntityLoader != NULL) {
  such that xmlFree(newURL) is called regardless of the second
  condition.

Thanks to Ralf H. for updating https://github.com/rhabacker/umbrello

CCBUG: 340646
parent 8160ef4c
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2002-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
SPDX-FileCopyrightText: 2002-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
*/
// own header
......@@ -49,7 +49,8 @@ SelectOperationPage::SelectOperationPage(UMLView *parent, UMLClassifier *c, Link
m_id(CUSTOM),
m_pView(parent),
m_classifier(c),
m_widget(widget)
m_widget(widget),
m_enableAutoIncrement(false)
{
QVBoxLayout * topLayout = new QVBoxLayout(this);
......@@ -149,6 +150,7 @@ void SelectOperationPage::setCustomOp(const QString &op)
*/
void SelectOperationPage::slotAutoIncrementChecked(bool state)
{
m_enableAutoIncrement = state;
if (state && m_pSeqLE->text().isEmpty())
m_pSeqLE->setText(m_pView->umlScene()->autoIncrementSequenceValue());
}
......
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2002-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
SPDX-FileCopyrightText: 2002-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
*/
// own header
......@@ -145,6 +145,7 @@ void SelectOperationDialog::setCustomOp(const QString &op)
*/
void SelectOperationDialog::slotAutoIncrementChecked(bool state)
{
m_enableAutoIncrement = state;
if (state && m_pSeqLE->text().isEmpty())
m_pSeqLE->setText(m_pView->umlScene()->autoIncrementSequenceValue());
}
......
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2008-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
SPDX-FileCopyrightText: 2008-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
*/
#include "docbookgeneratorjob.h"
......@@ -91,14 +91,16 @@ static xmlParserInputPtr xsltprocExternalEntityLoader(const char *_URL, const ch
newURL = xmlStrdup((const xmlChar *) paths[i]);
newURL = xmlStrcat(newURL, (const xmlChar *) "/");
newURL = xmlStrcat(newURL, (const xmlChar *) lastsegment);
if (newURL != NULL && defaultEntityLoader != NULL) {
ret = defaultEntityLoader((const char *)newURL, ID, ctxt);
if (ret != NULL) {
if (warning != NULL)
ctxt->sax->warning = warning;
qDebug() << "Loaded URL=\"" << newURL << "\" ID=\"" << ID << "\"";
xmlFree(newURL);
return(ret);
if (newURL != NULL) {
if (defaultEntityLoader != NULL) {
ret = defaultEntityLoader((const char *)newURL, ID, ctxt);
if (ret != NULL) {
if (warning != NULL)
ctxt->sax->warning = warning;
qDebug() << "Loaded URL=\"" << newURL << "\" ID=\"" << ID << "\"";
xmlFree(newURL);
return(ret);
}
}
xmlFree(newURL);
}
......
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2019-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
SPDX-FileCopyrightText: 2019-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
*/
#include "diagramproxywidget.h"
......@@ -362,10 +362,11 @@ void DiagramProxyWidget::slotMenuSelection(QAction* action)
} while(ok && !Diagram_Utils::isUniqueDiagramName(Uml::DiagramType::State, name));
if (ok) {
Uml::CmdCreateDiagram* d = new Uml::CmdCreateDiagram(UMLApp::app()->document(), Uml::DiagramType::State, name);
UMLScene *scene = d->view()->umlScene();
UMLApp::app()->executeCommand(d);
setShowLinkedDiagram(false);
setDiagramLink(d->view()->umlScene()->ID());
d->view()->umlScene()->setWidgetLink(m_widget);
setDiagramLink(scene->ID());
scene->setWidgetLink(m_widget);
}
}
break;
......
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