mirror of https://github.com/KDE/kasts.git
Fix bug with empty feed causing nullptr dereference
If an empty URL was entered (i.e. only whitespace) then that would be accepted and added to the database as temporary entry to be loaded and checked later. However, sqlite will convert this to a NULL entry. This would lead to Kasts not being able to retrieve that feed from the DB, and hence not being able to create a proper object. This would then lead to a nullptr dereference down the line. Note that this is a corner case: other invalid URLs are spotted correctly and do not cause the application to crash. BUG: 467394
This commit is contained in:
parent
56b30203eb
commit
45e50e40fb
|
@ -322,14 +322,23 @@ void DataManager::addFeeds(const QStringList &urls)
|
|||
|
||||
void DataManager::addFeeds(const QStringList &urls, const bool fetch)
|
||||
{
|
||||
if (urls.count() == 0)
|
||||
// First check if the URLs are not empty
|
||||
// TODO: Add more checks like checking if URLs exist; however this will mean async...
|
||||
QStringList newUrls;
|
||||
for (const QString &url : urls) {
|
||||
if (!url.trimmed().isEmpty()) {
|
||||
newUrls << url.trimmed();
|
||||
}
|
||||
}
|
||||
|
||||
if (newUrls.count() == 0)
|
||||
return;
|
||||
|
||||
// This method will add the relevant internal data structures, and then add
|
||||
// a preliminary entry into the database. Those details (as well as entries,
|
||||
// authors and enclosures) will be updated by calling Fetcher::fetch() which
|
||||
// will trigger a full update of the feed and all related items.
|
||||
for (QString url : urls) {
|
||||
for (const QString &url : newUrls) {
|
||||
qCDebug(kastsDataManager) << "Adding feed";
|
||||
if (feedExists(url)) {
|
||||
qCDebug(kastsDataManager) << "Feed already exists";
|
||||
|
|
Loading…
Reference in New Issue