From 82cb5b6f6407405ac25f0788a55e29a983b49193 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 21 Jan 2020 21:06:00 +0100 Subject: [PATCH] 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. --- Libraries/LibGUI/GFileSystemModel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libraries/LibGUI/GFileSystemModel.cpp b/Libraries/LibGUI/GFileSystemModel.cpp index 27d261654da..0aa57d8c3d9 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).reify_if_needed(*this); if (row >= node.children.size())