From cb71de48b8ca158991689a9f94e654380adb073c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quang=20Ng=C3=B4?= Date: Tue, 10 Nov 2026 16:04:43 +0700 Subject: [PATCH] Fix out of bound access when torrent change its file count Crash happen when the user open the torrent properties dialog while torrent finishes downloading its metadata from magnet link. --- src/ui/screens/torrentproperties/torrentfilesmodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ui/screens/torrentproperties/torrentfilesmodel.cpp b/src/ui/screens/torrentproperties/torrentfilesmodel.cpp index 51554a66..1604cbd9 100644 --- a/src/ui/screens/torrentproperties/torrentfilesmodel.cpp +++ b/src/ui/screens/torrentproperties/torrentfilesmodel.cpp @@ -142,10 +142,12 @@ namespace tremotesf { } void TorrentFilesModel::update(std::span changed) { + if (mFiles.size() != mTorrent->files().size()) { + mCoroutineScope.launch(createTree()); + return; + } if (mLoaded) { updateTree(changed); - } else { - mCoroutineScope.launch(createTree()); } }