Skip to content

Commit bdfb2b6

Browse files
committed
Guard dropEvent against empty URL list
Calling constLast() on an empty QList crashes. Although dragEnterEvent only accepts drops with hasUrls(), the MIME data could theoretically change between the drag-enter and drop events, so guard explicitly. https://claude.ai/code/session_01KvuREfVMg7MnzkpLBg8NVz
1 parent ae64096 commit bdfb2b6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/dialogs/importmbcdialog.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,13 @@ void ImportMbcDialog::dragEnterEvent(QDragEnterEvent* e)
233233

234234
void ImportMbcDialog::dropEvent(QDropEvent* e)
235235
{
236-
const QString filename(e->mimeData()->urls().constLast().toLocalFile());
236+
const QList<QUrl> urls = e->mimeData()->urls();
237+
if (urls.isEmpty())
238+
{
239+
return;
240+
}
241+
242+
const QString filename(urls.constLast().toLocalFile());
237243

238244
_pUi->lineMbcfile->setText(filename);
239245
_pGuiModel->setLastMbcImportedFile(filename);

0 commit comments

Comments
 (0)