[neon/kf6/kf6-kservice/Neon/release] debian/patches: backport recommended patch to not be so crashy

Carlos De Maine null at kde.org
Fri Feb 27 01:59:52 GMT 2026


Git commit 1e67e53538cf7ce3f3d1fdd746048f209b328b38 by Carlos De Maine.
Committed on 27/02/2026 at 01:59.
Pushed by carlosdem into branch 'Neon/release'.

backport recommended patch to not be so crashy

A  +73   -0    debian/patches/dont-crash.diff
A  +1    -0    debian/patches/series

https://invent.kde.org/neon/kf6/kf6-kservice/-/commit/1e67e53538cf7ce3f3d1fdd746048f209b328b38

diff --git a/debian/patches/dont-crash.diff b/debian/patches/dont-crash.diff
new file mode 100644
index 0000000..951d205
--- /dev/null
+++ b/debian/patches/dont-crash.diff
@@ -0,0 +1,73 @@
+diff --git a/src/sycoca/ksycocafactory.cpp b/src/sycoca/ksycocafactory.cpp
+index 0100226bb253e2e26ee0745fb4206f6d457a80ce..7bb0d4826cbdc3a48d22d2705de02bd25248273b 100644
+--- a/src/sycoca/ksycocafactory.cpp
++++ b/src/sycoca/ksycocafactory.cpp
+@@ -34,27 +34,42 @@ public:
+     int m_beginEntryOffset = 0;
+     int m_endEntryOffset = 0;
+     KSycocaDict *m_sycocaDict = nullptr;
++    // Used to avoid crashes when the factory failed to locate an actual data stream.
++    // Mind that we need a backing buffer since callers also tap into the stream's QIODevice.
++    QByteArray m_fallbackBuffer;
++    QDataStream m_fallbackStream{m_fallbackBuffer};
+ };
+ 
+ KSycocaFactory::KSycocaFactory(KSycocaFactoryId factory_id, KSycoca *sycoca)
+     : m_sycoca(sycoca)
+     , d(new KSycocaFactoryPrivate)
+ {
+-    if (!m_sycoca->isBuilding() && (m_str = m_sycoca->findFactory(factory_id))) {
+-        // Read position of index tables....
+-        qint32 i;
+-        (*m_str) >> i;
+-        d->m_sycocaDictOffset = i;
+-        (*m_str) >> i;
+-        d->m_beginEntryOffset = i;
+-        (*m_str) >> i;
+-        d->m_endEntryOffset = i;
+-
+-        QDataStream *str = stream();
+-        qint64 saveOffset = str->device()->pos();
+-        // Init index tables
+-        d->m_sycocaDict = new KSycocaDict(str, d->m_sycocaDictOffset);
+-        saveOffset = str->device()->seek(saveOffset);
++    if (!m_sycoca->isBuilding()) {
++        m_str = m_sycoca->findFactory(factory_id);
++        if (m_str) {
++            // Read position of index tables....
++            qint32 i;
++            (*m_str) >> i;
++            d->m_sycocaDictOffset = i;
++            (*m_str) >> i;
++            d->m_beginEntryOffset = i;
++            (*m_str) >> i;
++            d->m_endEntryOffset = i;
++
++            QDataStream *str = stream();
++            qint64 saveOffset = str->device()->pos();
++            // Init index tables
++            d->m_sycocaDict = new KSycocaDict(str, d->m_sycocaDictOffset);
++            saveOffset = str->device()->seek(saveOffset);
++        } else {
++            qWarning() << "Could not find factory with id" << int(factory_id)
++                       << "in sycoca database, you must run kbuildsycoca first! Creating a fake stream to not crash.";
++            m_str = &d->m_fallbackStream;
++            m_entryDict = new KSycocaEntryDict;
++            d->m_sycocaDict = new KSycocaDict;
++            d->m_beginEntryOffset = 0;
++            d->m_endEntryOffset = 0;
++        }
+     } else {
+         // We are in kbuildsycoca -- build new database!
+         m_entryDict = new KSycocaEntryDict;
+@@ -186,8 +201,8 @@ KSycocaEntry::List KSycocaFactory::allEntries() const
+     qint32 entryCount;
+     (*str) >> entryCount;
+ 
+-    if (entryCount > 8192) {
+-        qCWarning(SYCOCA) << QThread::currentThread() << "error detected in factory" << this;
++    if (entryCount < 0 || entryCount > 8192) { // mind that new accepts a size_t (unsigned) but we are dealing with an int here
++        qCWarning(SYCOCA) << QThread::currentThread() << "error detected in factory" << this << entryCount;
+         KSycoca::flagError();
+         return list;
+     }
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..4701132
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+dont-crash.diff


More information about the Neon-commits mailing list