diff options
author | Andreas Kling <kling@serenityos.org> | 2020-01-21 21:06:00 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-01-21 21:55:25 +0100 |
commit | 82cb5b6f6407405ac25f0788a55e29a983b49193 (patch) | |
tree | bda660ca75fd929075813f5051d1e6969cec0b12 | |
parent | ecd5589d4f8753e5f7c54299e58b1942937f84e2 (diff) | |
download | serenity-82cb5b6f6407405ac25f0788a55e29a983b49193.zip |
LibGUI: GFileSystemModel::index() now survives negative inputs
If asked to create an index with negative row and/or column, we should
just return an invalid GModelIndex() instead of asserting.
-rw-r--r-- | Libraries/LibGUI/GFileSystemModel.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GFileSystemModel.cpp b/Libraries/LibGUI/GFileSystemModel.cpp index 27d261654d..0aa57d8c3d 100644 --- a/Libraries/LibGUI/GFileSystemModel.cpp +++ b/Libraries/LibGUI/GFileSystemModel.cpp @@ -297,6 +297,8 @@ const GFileSystemModel::Node& GFileSystemModel::node(const GModelIndex& index) c GModelIndex GFileSystemModel::index(int row, int column, const GModelIndex& parent) const { + if (row < 0 || column < 0) + return {}; auto& node = this->node(parent); const_cast<Node&>(node).reify_if_needed(*this); if (row >= node.children.size()) |