Bug 457285 - KConfigWatcher::config() returns nullptr when built without DBUS support
Summary: KConfigWatcher::config() returns nullptr when built without DBUS support
Status: ASSIGNED
Alias: None
Product: frameworks-kconfig
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Matthew Dawson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-29 22:19 UTC by Kamil Dudka
Modified: 2022-08-10 13:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
[PATCH] KConfigWatcher: initialize d->m_config in constructor (1.05 KB, patch)
2022-07-29 22:30 UTC, Kamil Dudka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kamil Dudka 2022-07-29 22:19:43 UTC
As additional KDE applications started to use KConfigWatcher, they started to crash on my laptop running Gentoo Linux.  I was trying to patch them one by one to prevent the crashes.  Then I realized that kconfig was built without dbus support on my system.  After rebuilding kconfig with -DKCONFIG_USE_DBUS, the crashes went away.

I looked into the source code of KConfigWatcher and discovered that its constructor initializes d->m_config only if KCONFIG_USE_DBUS is defined: https://github.com/KDE/kconfig/blob/491f5464/src/core/kconfigwatcher.cpp#L47

Consequently KConfigWatcher::config() may return nullptr, which triggers null dereference at caller's side, where a non-null value is expected.

STEPS TO REPRODUCE
1. build kconfig without dbus support

OBSERVED RESULT
Applications like plasma or kwin start to crash.

EXPECTED RESULT
No crashes.

SOFTWARE/OS VERSIONS
Linux: 5.15.52-gentoo-x86_64
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.5

ADDITIONAL INFORMATION
Previously reported with backtraces at:
bug #423864 comment #4
bug #453242
Comment 1 Kamil Dudka 2022-07-29 22:30:16 UTC
Created attachment 150988 [details]
[PATCH] KConfigWatcher: initialize d->m_config in constructor
Comment 2 Kamil Dudka 2022-08-05 08:16:21 UTC
I have submitted a merge request to fix this: https://invent.kde.org/frameworks/kconfig/-/merge_requests/134