Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix potential crash when retrieving GlyphModel parent index.

Wolthera van Hövell tot Westerflier93125688e5b5
diff --git a/libs/flake/text/KoFontGlyphModel.cpp b/libs/flake/text/KoFontGlyphModel.cpp
index f6394f6ad6..6014017881 100644
--- a/libs/flake/text/KoFontGlyphModel.cpp
+++ b/libs/flake/text/KoFontGlyphModel.cpp
@@ -434,14 +434,16 @@ QModelIndex KoFontGlyphModel::parent(const QModelIndex &child) const
}
Private::InfoNode *node = static_cast<Private::InfoNode*>(child.internalPointer());
- for(int i = 0; i < d->codePoints.size(); i++) {
- Private::CodePointInfo info = d->codePoints.at(i);
- if (info.ucs == node->ucs) {
- return index(i, 0, QModelIndex());
+ if (node) {
+ const uint targetUcs = node->ucs;
+ for(int i = 0; i < d->codePoints.size(); i++) {
+ Private::CodePointInfo info = d->codePoints.at(i);
+ if (info.ucs == targetUcs) {
+ return index(i, 0, QModelIndex());
+ }
}
}
-
return QModelIndex();
}