core/unit: fix superficial NULL-pointer dereference

Though, when unit_prepare_exec() is called, the unit should always
have the cgroup runtime context 'crt'. So, I think we can insert assert().
But, for consistency with other places that call unit_get_cgroup_runtime(),
here use the simple non-NULL check for 'crt' instead of using assert().

Follow-up for 9cc545447e.

Fixes CID#1534667.
This commit is contained in:
Yu Watanabe
2024-02-17 16:50:46 +09:00
parent e7cf5c82da
commit ad48cc6f81
+1 -1
View File
@@ -5813,7 +5813,7 @@ int unit_prepare_exec(Unit *u) {
(void) unit_realize_cgroup(u);
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
if (crt->reset_accounting) {
if (crt && crt->reset_accounting) {
(void) unit_reset_accounting(u);
crt->reset_accounting = false;
}