From 41b2c477b771e7c214d09138af1a48701f573912 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 27 Jan 2020 13:12:45 +0100 Subject: Take care of NULL data from QStringView in QCollator Back-ends need to catch NULL data so as not to call system APIs with invalid pointers. [ChangeLog][QtCore][QCollator] Fixed a regression introduced in 5.14.0 that caused QCollator not to operate with default-constructed QStrings and print a warning on Windows. Fixes: QTBUG-81673 Change-Id: I2eafe1e188b436afcca3cf2ecdf98bba707c44c9 Reviewed-by: Thiago Macieira --- src/corelib/text/qcollator_macx.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/corelib/text/qcollator_macx.cpp') diff --git a/src/corelib/text/qcollator_macx.cpp b/src/corelib/text/qcollator_macx.cpp index 071d7c048f..cb8e073d4a 100644 --- a/src/corelib/text/qcollator_macx.cpp +++ b/src/corelib/text/qcollator_macx.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Aleix Pol Gonzalez +** Copyright (C) 2020 Aleix Pol Gonzalez ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -94,6 +94,11 @@ void QCollatorPrivate::cleanup() int QCollator::compare(QStringView s1, QStringView s2) const { + if (!s1.size()) + return s2.size() ? -1 : 0; + if (!s2.size()) + return +1; + if (d->dirty) d->init(); if (!d->collator) -- cgit v1.2.3